I have a url Like
http://localhost/coupon/stores.php?store_slug=url
I want to change it like this
http://localhost/coupon/url
I tried with this code
RewriteEngine on
RewriteBase /coupon/
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule (.*) stores.php?store_slug=$1
but its not working with the above mentioned .htaccess code am getting 500 internal server error. I am using this .htaccess file in sub folder ie coupon
can anybody check where am doing wrong ?
Give this a try:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /coupon/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) stores.php?store_slug=$1 [L]
There should no spaces between !
and -f/d
.
Keep in mind that the above rule is only to make http://localhost/coupon/url
work, as it will internally redirect any requests from the coupon
folder to the stores.php
file.
As an additional note, for the CSS, JS, Images, you will need to use absolute path, as using the relative path will assume that the CSS, JS and Images are inside the coupon folder.
So if you had it like this css/my.css
it will think it is inside coupon/css/my.css
so you need to use it as http://yourdomain.com/css/my.css
to avoid that.
And if you place a /
after the URL it will it will think that's the folder so it would go like this coupon/flipkart/css/my.css
.
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.