I have troubles with mod_rewrite.
I have wordpress site located in ‘wp’ directory. It is accessible as http://localhost/wp/
There is page http://localhost/wp/sample-page/ on the site.
I want to make this page open with url http://localhost/wp/sample-page-2/ without redirect.
Here is what in .htaccess file:
RewriteEngine On
RewriteBase /wp/
RewriteRule ^sample-page-2/$ sample-page/ [L]
But I’m getting 404 error.
Could somebody explain me what I’m doing wrong?
Thanks in advance.
UPD:
@soju: Well, “sample-page-2” – is just example
- It is not a page/post in worpress sence.
- Actually I tried to add one section to the url. E.g.
http://localhost/wp/sample-page/section/. And this ruleRewriteRule ^sample-page/section/$ sample-page/ [L]didn’t work. Then I decided to “simpliyfy” url(“sample-page-2” instead of “sample-page/section”) – no success.
UPD2
BTW, redirect RewriteRule ^sample-page-2/$ sample-page/ [R=301,L] works
I suppose wordpress rewrite rules are after your own rule, so you should remove
[L]option to let wordpress handlesample-pageurlEDIT about UPD2 : Well, it works with a 301 redirection, but you said you don’t want redirection ?
You can add a filter on
rewrite_rules_arrayto make your own rewrite rule, take a look at example on codex : http://codex.wordpress.org/Class_Reference/WP_Rewrite#Examples