0

I'm trying to rewrite my portfolio URLs within a htaccess file. I have this code and it work to some extent.

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ RewriteRule ^(.*)$ $1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^\.]+)/$ $1.php 

However the issue is that I have a blog in a folder and when I try to go to another page from the blog page the URL does not get formatted right. Ex. cgarcia.design/blog/about/ and it should be cgarcia.design/about/.

Any suggestions on how I can fix the code to properly rewrite my URLs with a trailing slash that also work with sub directories?

2
  • Does /blog/ also have a .htaccess? If yes then post it in question. Commented Jun 16, 2015 at 8:32
  • No, blog doesn't have a htaccess currently. Commented Jun 17, 2015 at 6:29

1 Answer 1

1

use the below line of code:

RewriteRule blog/(.*) / [L] 

Which basically means that whatever the request that comes as blog/any_name_here should be rewritten as /

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.