English 中文(简体)
.htaccess mod_rewrite has different result on different sites
原标题:

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.

最佳回答

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.

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签