1

Can we rewrite bellow url in wordpress site?

I want to hit the following wordpress url:

 test/test-post/index.shtml

with this url "custom" is my folder at root path and custom.php file

custom/custom.php?cat=1

Any help would be greatly appreciated, I've been struggling with this. Thanks in advance!

0

This will do it:

RewriteEngine on
RewriteRule ^test/test-post/index.shtml$ custom/custom.php?cat=1 [L,R]

The [L] flag causes mod_rewrite to stop processing the rule set.

Use of the [R] flag causes an HTTP redirect to be issued to the browser.

  • Thanks, but none of the above helps. Redirection not working.currently my htaccess is # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /dexter-armystudy/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /dexter-armystudy/index.php [L] </IfModule> # END WordPress – Dixita Nov 20 '17 at 11:21
  • i have trying in my local server. So, is it working on local server or not? – Dixita Nov 20 '17 at 11:24
  • Retested and work on my local and remote server. RewriteEngine on RewriteRule ^test/test-post/index.shtml$ custom/custom.php?cat=1 [L,R] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /dexter-armystudy/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /dexter-armystudy/index.php [L] </IfModule> # END WordPress . Navigate to example.com/test/test-post/index.shtml and it will redirect you to the example.com/custom/custom.php?cat=1 – Drupalizeme Nov 20 '17 at 11:27
  • If "custom is my folder at root path" then you will need a slash prefix on the RewriteRule substitution, otherwise, it is going to be redirected relative to the RewriteBase, which appears to be set to /dexter-armystudy/. However, is an external redirect required here? The question states "rewrite". If an internal rewrite is required then you'll also need to remove the R flag. – MrWhite Nov 24 '17 at 23:41

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.