Hi I’m developing a website and all .php files are located in the main folder on the server (where .htaccess is).
So index.php and productDetail.php are in the same folder.
I want to redirect a url like this :
http://www.mywebsite/productDetail/PRODUCTNAME
to
http://www.mywebsite/productDetail.php?product=PRODUCTNAME
so that I can link the first link version instead of the second.
I also need to redirect a more complicated version, like:
http://www.mywebsite/PRODUCTCATEGORY/PRODUCTSUBCATEGORY/productDetail/PRODUCTNAME
to
My .htaccess currently uses the following rules that I think are making really difficult this operation because I’ve been working on it a lot of time :
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
RewriteCond %{THE_REQUEST} !s/(it|en)/ [NC]
RewriteCond %{HTTP:Accept-Language} ^it [NC]
RewriteRule ^ /it%{REQUEST_URI} [L,NC,R=301]
RewriteCond %{THE_REQUEST} !s/(it|en)/ [NC]
RewriteRule ^ /en%{REQUEST_URI} [L,NC,R=301]
RewriteRule ^(en|it)/(.*)$ $2?lang=$1 [L,QSA,NC]
Any help would be appreciated.
Thanks a lot
2
Answers
You can use a Rule of the following form :
The Rule with Regex patterns :
This will internally redirect /productDetail/foo to /productDetail.php?product?foo.
Try these rules: