Clean URLs for a PHP rookie

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

yep, sure does
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

I opened YaST to check my setup, opened Network Services, opened HTTP Server, opened Server Modules, it indicates that rewrite is enabled and running.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

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.
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

Here's my <directory> tag:

Code: Select all

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Deny from all
</Directory>
Please don't give up on me, I'm sure it's something simple.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Try this...

Code: Select all

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

No change.

Here's a stupid question. Is the .htaccess file just a text file?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Yes it is, but it for certain has to be named .htaccess and it should be written with a plain text editor.
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

That's what I thought, I'm kinda grasping at straws now. What else can I check?
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

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:

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>
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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think you can use the diff command at the command line to view the differences between your conf and the one you unpacked.
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

What's the diff command? Can you give me an example?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

user@host $> diff file1 file2
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

I 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

Code: Select all

Options FollowSymLinks
AllowOverride All
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

So it is working then? I wonder why the setup I mentioned a few posts up didn't work, as the <directory /> should have affected everything in the root.
Bill_VA
Forum Commoner
Posts: 26
Joined: Sat Mar 03, 2007 8:07 pm

Post by Bill_VA »

Idunno, go figure. The Options FollowSymLinks and AllowOverride All lines apparently need to be in both places.
Post Reply