Skip to main content
2 of 2
Formatting, grammar, spelling
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

Url rewrite not work in wamp localhost

I am developing a PHP web application. I have pages, posts, categories, product and etc.

Here is my .htaccess file to create SEO friendly URL:

Options -Indexes
RewriteEngine on
RewriteRule ^Page/(.*)/(.*)$ Page.php?Page_Id=$1&Page_Title=$2 [NC,L]
RewriteRule ^Product/(.*)/(.*)$ Product.php?Product_Id=$1&Product_Title=$2 [NC,L]
RewriteRule ^Category/(.*)/(.*)$ Category.php?Category_Id=$1&Category_Title=$2 [NC,L]
RewriteRule ^Single/(.*)/(.*)$ Single.php?Post_Id=$1&Post_Title=$2 [NC,L]
RewriteRule ^Blog/(.*)/(.*)$ Blog.php?Category_Id=$1&Category_Title=$2 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
 

<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 year"
</IfModule>

When I visit Page.php?Page_Id=13 it works. And also when I visit Page/13/Page-Title it works. Everything is good when I test my application on the server, but it doesn't work in wamp localhost.

I active

LoadModule rewrite_module modules/mod_rewrite.so

in Apache http.conf and here is my vhost:

    <VirtualHost *:8080>
    ServerName localhost
    DocumentRoot c:/wamp64/www
    <Directory  "c:/wamp64/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>


<VirtualHost *:8080>
    ServerName schoolarshop
    DocumentRoot "c:/wamp64/www/schoolarshop"
    <Directory  "c:/wamp64/www/schoolarshop/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride none
        Require local
    </Directory>
</VirtualHost>

Example of error in localhost is:

Notice: Undefined index: Page_Id in Page.php on line 8

Why does it work on the server and not in localhost?

I Googled a lot but it can't find anything.