EDIT** I know the title is spelled wrong, no need to tell me about it again. Can a moderator please change it? Hello all, I own tackypenguin.com and I need help on a mod rewrite problem. Right now I have the following code on my .htaccess file <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^/([a-zA-Z]+)$ /index.php?page=$1 RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)$ /index.php?page=$1&do=$2 </IfModule> Code (markup): Basically, I want it to take tackypenguin.com/user or any other word, and make it get tackypenguin.com/index.php?page=user or whatever word. Then, I would like it to have two directories, like tackypenguin.com/user/login and make it get tackypenguin.com/index.php?page=user&do=login. Right now when I try to do this, if i go to tackypenguin.com/user, it gives me my 404 error. Any help would be greatly appreciated.
I put in tackypenguin.com/user It should be getting tackypenguin.com/index.php?page=user My index.php page has my design, then it uses include to add in the content from user.php. it says that tackypenguin.com/user/ cannot be found, which means my mod rewrite is not working somehow. because it thinks tackypenguin.com/user/ is a real directory.
Try removing the "/" from the first RewriteRule: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([a-zA-Z]+)$ /index.php?page=$1 RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)$ /index.php?page=$1&do=$2 </IfModule> Code (markup):
Try this code: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z]+)/?$ /index.php?page=$1 RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/?$ /index.php?page=$1&do=$2 </IfModule> Code (markup): I added a check to make sure the requested file doesn't exist (in which case it wouldn't redirect to index.php), and added testing for optional trailing slashes in the URL.
Thank you sooo much. This fixed it. This was bugging me so much, but now its fixed! Once again, thank you.