Options +FollowSymLinks give error 500!? Why?

Hi all,

I’m trying to create SE friendly URL’s from this URL:

http://www.mysite.co.uk/vehicle_detail.php?detailID=409

But I’m not getting much joy. Here’s the .htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteRule vehicle_detail-detailID-(.*)\.html$ vehicle_detail.php?detailID=$1

When I upload and test I get an Internal Server 500 error. If I comment out the Options +FollowSymLinks I no longer get the error.

Could this mean that the FollowSymLinks option may not be available on my server?

Anyway, any help here would be gratefully received.

Rob

Hi Rob,
you’re pushing your head too far I think. :slight_smile:

If you’re using an .htaccess, no need for the Options FollowSymLinks bit.

I have rewritten your rule so to strengthen it a little bit more.


RewriteEngine On
RewriteRule ^vehicle_detail-detailID-([0-9]+)\\.html$ vehicle_detail.php?detailID=$1 [NC,L]

You don’t need the .html bit, but that’s up to you to keep it.

:slight_smile:

Thanks very much for getting back to me and improving the rule. Sadly, the URL’s are not changing, they still look like:

http://www.mysite.co.uk/vehicle_detail.php?detailID=410

No error 500 this time though. I’m surprised that I don’t need the Options +FollowSymLinks bit but you’re right I am probably trying to run before I can walk with this.

Do you have any notion as to why the URL’s are the same?

A rewrite rule will not modify the look of your URL, it will just take an URL and internally turn it into another one :slight_smile:

Now I’m confused! Why does all the SEO stuff recommend using rewrite to change to URL’s into a friendly form for the SE’s? I understand that Apache does this internally but the optimised URL can be seen in the browsers address bar!? It sounds as though I’m missing something fundemental here.

The links you have on your website must be the “friendly” ones. Then mod-rewrite translates them, as the visitor clicks on them, to the ugly ones internally.

You have on your site:

<a href=“/country/australia/state/victoria”>Victoria, Australia</a>

mod-rewrite gets fed this:

RewriteRule ^/country/([a-z]+)/state/([a-z]+)$ /info.php?country=$1&state=$2 [L]

Visitor clicks on above link. mod-rewrite translates it to this ugly one internally:

/info.php?country=australia&state=victoria

In other words, mod-rewrite doesn’t translate your HTML on the fly from ugly to user-friendly. It does the opposite: translating the user-friendly to the ugly.

Thanks for the reply, but I can’t grasp what you just said:

The links you have on your website must be the “friendly” ones. Then mod-rewrite translates them, as the visitor clicks on them, to the ugly ones internally.

But it’s a dynamic site and ugly URL’s are the way it is. I can’t see how I can make friendly URL’s before mod_rewrite get’s at them. This is a naturally developed URL from the site:

http://www.mysite.co.uk/vehicle_detail.php?detailID=409

From your last reply the URL’s on my site should look like:

http://www.mysite.co.uk/vehicle_detail/409

or something similar. But how on earth do I do this before it get’s re-written into the ugly form within mod_rewrite !?!

Please excuse my obvious lack of understanding on this. Now I know I’m definitely missing some vital info.

Dynamic sites can generate any kind of URL, ugly or friendly. Your scripts must print out friendly URLs like http://www.mysite.co.uk/vehicle_detail/409

However, if the visitor loads a URL like that, your web server wouldn’t know which script to pass it on to. mod-rewrite’s job is to tell your web server that if you see the URL like the above, then it really is http://www.mysite.co.uk/vehicle_detail.php?detailID=409, so send the request to /vehicle_detail.php with that query string.

In other words, you fix your scripts to print friendly URLs first. If it prints the ugly URLs then that’s all your visitors will see and there will be no rewrites.

Ok, I think I getting there. So I need to make the site print friendly URL’s and THEN get apache to rewrite them to the ugly form internally. Right, I see. I’m thinking I can make friendly URL’s with PHP PATH_INFO? Am I on the right lines here? Although it seems I may have a problem here as when I print_r($_SERVER[‘PATH_INFO’]) I get nothing!

Rob,

Now you’ve got it! As the webmaster, YOU create the SEO links and the regex to turn them back into your physical (internal) links so Apache can serve the correct script.

Go have a read of my signature article - it should help you understand a little better.

Regards,

DK

Yep, I’ve got it now! I tried it out with one page on the clients site and it works great. There’s a lot of work to convert the whole site but everyone around here says it will reap rewards re: search engine listing etc.

Thanks all

Rob

Rob,

:Partier:

Regards,

DK