Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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]
</IfModule>

# 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?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
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. –  toscho 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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