Clean URLs for a PHP rookie
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
This has to be something with the configuration for Apache. At least everything leads me to think that. But I am not sure what.
The last time I configured apache to use mod_rewrite (which was a few days ago) it was a matter of making the <directory /> entry into the conf and adding the Options FollowsymLinks and AllowOverride All portions to it. After that it was only a matter of tuning my rule set to get it working. I am totally not sure at all of what could be causing this issue for you.
The last time I configured apache to use mod_rewrite (which was a few days ago) it was a matter of making the <directory /> entry into the conf and adding the Options FollowsymLinks and AllowOverride All portions to it. After that it was only a matter of tuning my rule set to get it working. I am totally not sure at all of what could be causing this issue for you.
Here's my <directory> tag:
Please don't give up on me, I'm sure it's something simple.
Code: Select all
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Deny from all
</Directory>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Try this...
Code: Select all
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Good new and bad news. I found another forums site that had someone's entire apache setup all zipped up. I made a copy of my existing Apache folder and then unzipped their files into my folder, edited a few settings and then I started to get 500 server error issues instead of 404 and found that the rewrite function was now working but causing an error. I played around with the RewriteRule a bit and found that this works perfectly:
The only downside to this is that I have no clue as to what exactly it was that fixed it.
Robert, thanks so much for the help. I'm sure that given my rookie status, you'll see other posts from me in the future.
Bill
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ /mysite/index.php?city=$1&page=$2&function=$3 [L]
</IfModule>Robert, thanks so much for the help. I'm sure that given my rookie status, you'll see other posts from me in the future.
Bill
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Code: Select all
user@host $> diff file1 file2I found the difference in a file that causes this to work or not. In the /etc/apache2/
default-server.conf file, the <Directory "/srv/www/htdocs"> tag must have
default-server.conf file, the <Directory "/srv/www/htdocs"> tag must have
Code: Select all
Options FollowSymLinks
AllowOverride All- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA