简体   繁体   中英

.htaccess redirect without change url working in localhost but not working in server

Following is my code in .htaccess file:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /site

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

RewriteRule ^category/.*?/cat_(\d+)$ http://www.domainname.com/site/viewproducts.php?catid=$1 [NC,L]

The problem is when I visit

http://www.domainname.com/site/category/Food_Items/cat_<passed_id>

the address bar is changed to

http://www.domainname.com/site/viewproducts.php?catid=<passed_id>

Its just working fine in localhost without changing address bar, but in server it working but address bar is changed. My web server running in unix and localhost running in windows.

I can't find the answer. Plz somebody help to fix this issue.

Can you try changing the RewriteRule as follows:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /site

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f    
RewriteRule ^category/.*?/cat_(\d+)$ viewproducts.php?catid=$1 [NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM