0

I am making a .htaccess file with various mod_rewrite rules. At the moment, one of my rules is

RewriteRule ^blog /directorypath/index.php [L]

but when you type in http://www.example.com/blogfjdkkfnfdjn, it still loads the blog page.

Basically, I am looking for the regex for it to load the blog when JUST `/blog` is typed in and nothing else

4 Answers 4

1

You can use:

Redirect permanent /blog /directorypath/index.php

If you need a temporary you can use: 302 instead of permanent

OR

RewriteRule ^blog/?$ /directorypath/index.php [R=301,L]

If you need a temporary you can use: R=302

Sign up to request clarification or add additional context in comments.

Comments

0

If you access your blog via /blog or /blog/ then I would use

RewriteRule ^blog/?$ /directorypath/index.php [L]

Comments

0

Add the $ character to the expression

RewriteRule ^blog$ /directorypath/index.php [L]

Comments

0
RewriteRule ^blog$ /directorypath/index.php [L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.