VeeK VeeK - 2 months ago 6x
Apache Configuration Question

RewriteRule not working for one specific case

I'm banging my head on the wall with this one. I have a rewrite rule in my htaccess file which works for all urls but one. Here's the line

RewriteRule ^([a-zA-Z0-9_-]+)$ content.php?linkid=$1 [L]

And the complete htacess

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

#RewriteRule ^contact-us content.php?linkid=contact-us [L,R]
RewriteRule ^([a-zA-Z0-9_-]+)$ content.php?linkid=$1 [L]
RewriteRule ^news/([a-zA-Z0-9_-]+)/([0-9]+)$ media.php?news=$1&pgNo=$2 [L]
RewriteRule ^news-details/([a-zA-Z0-9_-]+)$ media-detail.php?news_short=$1 [L]
RewriteRule ^services-list/([a-zA-Z0-9_-]+)$ services-list-new.php?services_list=$1 [L]

RewriteRule ^specialities/([a-zA-Z0-9_-]+)/([0-9]+)$ speciality-listing.php?speciality=$1&pgNo=$2 [L]
RewriteRule ^services-details/([a-zA-Z0-9_-]+)$ services.php?speciality_short=$1 [L]
RewriteRule ^treatment-detail/([a-zA-Z0-9_-]+)$ treatment-detail.php?treatment_short=$1 [L]
RewriteRule ^testimonial/([a-zA-Z0-9_-]+)/([0-9]+)$ testimonials.php?testimonial=$1&pgNo=$2 [L]
RewriteRule ^testimonial-detail/([a-zA-Z0-9_-]+)$ testimonial-detail.php?test_short=$1 [L]
RewriteRule ^photo-gallery-detail/([a-zA-Z0-9_-]+)$ photo-gallery-detail.php?photo_short=$1 [L]
RewriteRule ^media/([a-zA-Z0-9_-]+)/([0-9]+)$ media.php?media=$1&pgNo=$2 [L]
RewriteRule ^media-detail/([a-zA-Z0-9_-]+)$ media-detail.php?media_detail=$1 [L]
RewriteRule ^doctor-profile/([a-zA-Z0-9_-]+)$ doctor.php?doc_short=$1 [L]
RewriteRule ^make-an-appointment/([a-zA-Z0-9_-]+)$ make-an-appointmen.php?appointment_id=$1 [L]
RewriteRule ^current-openings/([a-zA-Z0-9_-]+)/([0-9]+)$ current-openings.php?current_opening=$1&pgNo=$2 [L]


So this works for
which goes to
and a few others like testimonials, services, career etc

BUT, it doesn't work for contact-us, i.e.

I've even tried the hard coded version above which is the commented line above. Any ideas guys?

I've tried using the url
which works correctly but
gives me the error The requested URL /contact-us was not found on this server..

I've also discovered another url that's not working and it is
which says The requested URL /media.html/list/1 was not found on this server. I don't know where it's getting media.html from. There was a file named media.html in the file structure so I removed that and the link started working. That's not the case with contact-us though.


Translating above comments into an answer as it might help someone with similar problems.

You need to disable MultiViews options to make it work.

So just change your Options line this:

Options +FollowSymlinks -MultiViews

Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So if /file is the URL then Apache will serve /file.html.