Friday, March 23, 2018

.htaccess - rewrite rule does not rewrite url as expected

I have a problem with a CMS website, that normally generates readable urls. Sometimes it happens that navigation links are shown as www.domain.com/22, which results in an error, instead of www.domain.com/contact. I have not found a solution for this yet, but the page is working if the url is www.domain.com/index.php?id=22.



Therefore, I'm trying to rewrite www.domain.com/22 to www.domain.com/index.php?id=22 and I have used this rewrite rule:



RewriteRule ^([1-9][0-9]*)$ index.php?id=$1 [NC]



I tested it using http://htaccess.madewithlove.be and here it shows the correct result, but on the website no rewrite is happening.



Begin: Rewrite stuff





RewriteEngine On




RewriteRule ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic.php|favicon.ico)/ - [L]



RewriteRule ^typo3$ typo3/index_re.php [L]



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



RewriteRule .* index.php [L]




Options +FollowSymLinks



RewriteCond %{HTTP_HOST} ^domain.dk$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain-alias.com$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]



RewriteRule ^([1-9][0-9]*)$ index.php?id=$1 [NC]



End: Rewrite stuff

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...