.htaccess overwrite parameters not going to landing page.

I want to pass URL parameters, but the parameters are not being passed to the desired page.

Earlier my site was hosted on cpanel and below code works successfully, but after I moved my site to VPS server with Cent OS web panel using lacquer cache and apache running on server no parameters are passed to landing page / Url.

RewriteEngine on  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  

RewriteRule ^download/(.*).html download.php?q=$1 [L,QSA]

      

I want to run url: www.example.com/download/anything.html


and target url after rewriting www.example.com/download.php?q=anything


The problem is rewriterule works but no parameters are passed.

But if I use the below code the parameters pass successfully.

RewriteEngine on  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  

RewriteRule ^([a-zA-Z_0-9-]+)$ download.php?q=$1 [L,QSA]

      

or below code

RewriteEngine on  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*) download.php?q=$1 [L,QSA]

      

and I run the below url, the parameters are passed to the target page successfully
www.example.com/anything


target url:www.example.com/download.php?q=anything



but I want the url in the following format to www.example.com/download/*****.html

replace * Asterisk Sign with the actual request.

If I add some static text to the Rewrite url like download/

(. *) .html

, The parameters are not passed to the landing page.

thank

+3


source to share


1 answer


Most likely, the new server has default parameters MultiViews

. Place this line on top of your .htaccess to disable it:

Options -MultiViews

      



The option is MultiViews

used Apache content negotiation module

, which is executed before mod_rewrite

and makes the Apache server map to file extensions. So it /file

may be in the url, but it will serve /file.php

.

+2


source







All Articles