Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a .htaccess file on my main directory on my website, which basically allows pretty urls (example.com/index instead of example.com/index.html) and it will redirect to a pretty url if someone goes to example.com/index.html.

Here is the code that I use for this:

#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]

#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

The issue is that I have a sub domain on the website, forum.example.com/ and when I click on a link on the page, it will go to forum.example.com/forum/page/ which goes to a 404 error page, since it should be http://forum.example.com/page/

I suppose I could delete the 301 redirect in my .htaccess file, but I would like to keep that, as it makes the website look nicer.

share|improve this question
1. Why would rewrite rules on your main domain change how a subdomain operates? The sub-domain should be served out of a different folder. 2. Why do you think this redirect rule is changing /forom/page/ which doesn't end in .html 3. Why are you using %THE_REQUEST which should be a string like GET /index.html HTTP/1.1? I'd expect you to use %{REQUEST_FILENAME} there as well. – Stephen Ostermiller Feb 17 at 23:16

migrated from stackoverflow.com Feb 17 at 13:39

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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