Hello,
I'm quite newbie with Apache and need some help with URL rewritting and alias.
I'm trying to redirect all my URLs which are inside a /folder/ to the same URI without this /folder/.
For example:
www.example.com/folder/index
should be: www.example.com/index
So I first tried to rewrite the URL using the following code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^www\.example\.com\/folder(.*) http://www.example.com/$1 [R=301,L]
So: Anything that starts with an "www.example.com/folder" followed by "anything" should be retypped to an URL like "www.example.com/anything"
I've put this in a .htaccess file inside this /folder/.
I'm not sure if it's a problem with the code itself or if I should put it on the private_html folder.
I've tried a rewrite match too, how you can see:
RedirectMatch 301 ^www\.example\.com\/folder(.*) http://www.example.com/$1
But it also didn't work...I've tried some variations without the "^", without thoose "\" before de dots and nothing worked.
When I open the www.example.com/folder, it doesn't show up any error but just page as it is (in all of my tests). Is there something wrong? Also, I think my Apache settings are okay because there's a .htaccess file in the public_html which redirects all the non-www URLs to the respectives with the www and it works perfectly. I don't know why this code works and my other doesn't. The code is:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
And yes I've tried the folder code with this structure which contains RewriteCond and RewriteRule and it didn't work too.
I've tried to replace the public_html .htaccess with the code that should redirect my folder files, but it gives me an Internal Server Error.
I don't know what is wrong. I've read all the specifications for mod_alias and mod_rewritting and it should be okay. I think it can be an error with my regular expressions and I didn't see anywhere saying if I can use thoose rewrites in the same host. Can someone give me some help?
PS: I'm very sorry about my English. I know it may be a little difficult to understand, but I'd be very happy if someone had the pattience to help me (: