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

Enable URL rewriting

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

  • 1
    Is it possible that some other rule is acting on the url before this rule ? Enable mod_rewrite logging and see what's going on. – user9517 Jun 13 '14 at 7:35
  • Yes. That is possible. I will try what you suggest and get back to you – BrianB Jun 13 '14 at 8:39
  • Any tips on how to do that? I have ssh access to the shared server, but don't know much about apache settings – BrianB Jun 13 '14 at 9:45
  • Can you show all RewriteRules used on that site? – Tero Kilkanen Jun 14 '14 at 14:20
  • Yes - i added it to the original post – BrianB Jun 19 '14 at 10:25

You can try this one, is working on my websites

RewriteRule ^([0-9]+)$ /index.php?id=$1 [L,QSA]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.