I have one folder inside WordPress root folder named links and there is a file called index.php inside this folder. at somewhere else in my WordPress site I do generate links such as http://mysite.com/links/index.php?link=55 (there are more than one link).

How can I have specific rewrite rule (like http://mysite.com/link/55) for above link inside my .htaccess file that don't interrupt own WordPress rule and don't throw Internal Server Error?

Here is my .htaccess content:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteRule ^link/([^/]*)$ /wordpress/links/index.php?link=$1 [L]

RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]

# END WordPress

Currently I am on localhost and my wordpress folder is in /www/wordpress. but when I click http://localhost/link/50a25386721bb I get 404 error. what's wrong?


Catch those requests before WordPress can see them:

RewriteEngine On
RewriteBase /

RewriteRule ^link/(\d+)$ /links/index.php?link=$1 [L,QSA]

Place the WordPress rules below the link rules.

  • Please read first post as I did edit that based on what you said. thanks. – silvercover Nov 13 '12 at 16:01
  • @silvercover Try the rule I suggested, your variation cannot work. – fuxia Nov 13 '12 at 16:02
  • I've changed (\d+) to ([^/]*) because passed parameter may contain alpha numeric characters. I've also added [L,QSA] at the end but again I get 404! – silvercover Nov 13 '12 at 16:06

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.