davidrobles23
asked on
URL Mod Rewriting for Directory Slashes
I have a website with user accounts like these: http://www.mywebsite.com/username/
I have this .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/ user.php?uid=$1
It is working fine for urls with the /username/, but when users put the URL in the way http://www.mywebsite.com/username, I get Error 404
I have been trying a lot of RewriteRules, can anyone help me with this?
I have this .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/ user.php?uid=$1
It is working fine for urls with the /username/, but when users put the URL in the way http://www.mywebsite.com/username, I get Error 404
I have been trying a lot of RewriteRules, can anyone help me with this?
RewriteRule ^/?([a-zA-Z0-9_-]+)$ /$1/ [L]
allows letters, numbers, an underscore, and a hyphen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JamesCssl:... See.
for the images, css and others files, he will handle this from central configuration varaibles which is also recommended by experts. like:
define("fontEndUrl") = "http://mysite.com/";
define("images") = fontEndUrl."images";
define("css") = fontEndUrl."css";
Now developer will include this configuration file on all PHP pages and safely use url for images as follows:
<img src=<?=images?>raheel.jpg border=0 />
This simple and easy solution for handle such path issues without involment with .htaccess.
Cheers JamesCssl..... ;)
for the images, css and others files, he will handle this from central configuration varaibles which is also recommended by experts. like:
define("fontEndUrl") = "http://mysite.com/";
define("images") = fontEndUrl."images";
define("css") = fontEndUrl."css";
Now developer will include this configuration file on all PHP pages and safely use url for images as follows:
<img src=<?=images?>raheel.jpg border=0 />
This simple and easy solution for handle such path issues without involment with .htaccess.
Cheers JamesCssl..... ;)
ASKER
Thanks guys, with all the information I made it work excellent
Thanks again!!
Thanks again!!
RewriteRule ^/([a-zA-Z0-9_-]+)$ /$1/ [L]
I don't know what characters you allow in your usernames, so it may need to be tweaked slightly.