MOD REWRITE runs on the local host, but not on the server

First of all, I specified my hosting company, and they confirmed that the Allow Override option is enabled.

Secondly, if I write the garbage value in the .htaccess file, then I get "Internal server error", which once again proves that .htaccess is not skipped.

I am trying to do this Input: all / 3 output: all.php? id = 3

I wrote the following in a .htaccess file that I copied from the tutorial site.

# Enable Rewriting RewriteEngine on # Rewrite user URLs # Input: user/NAME/ # Output: user.php?id=NAME RewriteRule ^all/(\w+)/?$ all.php?id=$1 

all.php file

 <?php echo $_GET['id']; ?> 

Now, if I enter localhost/all/3 , then I get 3.

If I enter www.mydomain.com/all/3 , the page will be blank.

I also have only the above code in the .htaccess file and nothing more or less. So why am I having different behavior on the local host and on my server?

+4
source share
2 answers

try the following:

 RewriteRule ^all/(.*)$ all.php?id=$1 
0
source

It looks like your host has enabled the MultiViews option. The solutions are to make them disable it, or perhaps a faster option, rename your PHP file as something other than all.php only if the base name (minus the extension) does not match your RewriteRule pattern.

0
source

All Articles