Question

I am using mod_rewrite to create SEO URLs. Basically the thing works in the following way: all requests are caught by .htaccess and redirected to a php script (let's say transform.php). transform.php parses SEO URL and transforms it into a normal URL, then includes index.php, then catches application's (index.php's) output and uses RegEx to convert all normal URLs to SEO URLs. So the vital step is to make all request go through transform.php. My .htaccess is rather long however I managed to limit it to the following lines.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on

    RewriteRule ^index\.php?(.*)$ ./transform.php?p=$1&%{QUERY_STRING} [L]

</IfModule>

The problem happens with the initial (root) URL: http://mysite.com/. When I type http://mysite.com/ and site is located on my local comp, everything works fine. http://mysite.com/ is caught by .htaccess and sent to transform.php for further processing. However on another server this line doesn't work (let's say for http://mysite-other-server.com/). This .htaccess line simply doesn't catch the request. Everything works fine for http://mysite-other-server.com/index.php though.

Moreover I have several sites on this second server and some of them work while some of them don't. It's like for some of them the URL is first resolved to http://mysite-other-server.com/index.php and then handled by .htaccess while for others the URL is not resolved and .htaccess deals with http://mysite-other-server.com/

I am very confused and tried googling without any luck. Any help is highly appreciated.

Was it helpful?

Solution

I assume that Apache is configured not to accept .htacces files.

You must enable it from the httpd configuration with the AllowOverride setting.

http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride

Another possibility is that the production server hasn't loaded mod_rewrite, check the LoadModule directives for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top