简体   繁体   中英

mod_rewrite works fine on linux but returns forbidden on windows 10

I'm working with wampserver on windows 10 for local development.
after that i made my script live and it works fine but after some days i implemented url rewrite.
my scipts works fine on live server.
now i want to do some changes so i made it local for development and i'm getting Forbidden on my local host.

here is rewrite rules

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/([-\w]+)/(\d+)/([-\w]+)$ $1.php?cat_name=$2&vid=$3&vbiz_name=$4 [NC,L]
RewriteRule ^(.*)/([-\w]+)/(\d+)$ $1.php?cat_name=$2&page=$3 [NC,L]
RewriteRule ^(.*)/([-\w]+)$ $1.php?cat_name=$2 [NC,L]
RewriteRule ^(.*)/$ $1.php [NC,L]

# Error Documents
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ 404.php [L]

RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ 500.php [L]
</IfModule>

This is Virtual Host details i'm using.

<VirtualHost *:80>
    ServerName devproject
    DocumentRoot "g:/dev-project"
    <Directory  "g:/dev-project/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

index page works fine...
Please help me out..

Soved...
I just added new line

Options FollowSymLinks

just after

RewriteEngine on

And it works on windows as well as on linux both, New Rules looks like

<IfModule mod_rewrite.c>
RewriteEngine on
Options FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/([-\w]+)/(\d+)/([-\w]+)$ $1.php?cat_name=$2&vid=$3&vbiz_name=$4 [NC,L]
RewriteRule ^(.*)/([-\w]+)/(\d+)$ $1.php?cat_name=$2&page=$3 [NC,L]
RewriteRule ^(.*)/([-\w]+)$ $1.php?cat_name=$2 [NC,L]
RewriteRule ^(.*)/$ $1.php [NC,L]

# Error Documents
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ 404.php [L]

RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ 500.php [L]
</IfModule>

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