Forum Moderators: phranque
I'm using some software that is making my urls like:
h ttp://subdomain.mydomain.com/extra-directory/section1
I would like the urls to be like:
h ttp://subdomain.mydomain.com/section1
h ttp://subdomain.mydomain.com/section2
etc.
I don't think I can install the software in the root of the subdomain because I believe it refers back to the directory somewhere in the script.
The 'extra-directory' is kind of long and not a familiar word to most people.
I tried:
RewriteRule ^(.*)? extra-directory/$1 [L]
But it isn't working, I get a Error 404 - Not Found when trying to go to
h ttp://subdomain.mydomain.com/section1
It seems like this should be easy, but mod_rewrite always confuses me. I just muddle my way through it most of the time.
[edited by: Trisha at 8:57 pm (utc) on Jan. 8, 2007]
As a result, the rule
RewriteRule (.*) extra-directory/$1 [L]
If you reverse the rewrite, to:
RewriteRule ^extra-directory/(.*)$ /$1 [L]
So, neither mod_rewrite solution will work. If you want to change a link, it has be changed on the page that the visitor is looking at. You can then rewrite the requested URL, which is for a page in your Web root, back to the /extra-directory level where it actually resides. Of course, these on-page URLs must be sufficiently unique for mod_rewrite to determine that they need to be rewritten. Otherwise, it would rewrite *all* pages requested from your Web root to the /extra-directory level. :(
Jim
Thanks again