Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This is more a why question.

I'm using a CMS that handles clean URLs via mod_rewrite out of the box.

Website has a section /accessories that now has to be renamed to /store.

Being on lazy mode, I just wanted to do an internal rewrite using mod_rewrite, so, when accessing example.com/store/, I want content served from example.com/accessories, transparently, without any external redirect.

So far, I've tried this:

RewriteEngine On

# Internally rewrite /store to /accessories
RewriteRule ^store /accessories [L] #also tried with other flags like PT, N, C

# All below rules are provided by CMS
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]

RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php

But nothing worked.

The two only ways I could make this to work were:

  • by internally rewriting the request to its corresponding "messy" URL, like this:

    RewriteRule ^store /index.php?s=accessories [L]

  • by using mod_proxy and ProxyPass directive (which I discarded as solution, as mod_proxy is not available on production server).

I've just come up to the conclusion that URLs cannot be internally rewritten to other (fake) clean URLs, while keeping the rewrite chaining alive. By "fake" I mean URL paths that are not real filesystem paths (usually, folders) or real files (like index.php).

So, question is: Why?

share|improve this question
1  
To clarify, do you want something like /store/clothing/shirts/ to be rewritten to /accessories/clothing/shirts/ (which is then passed on to index.php by later rewrite rules)? Either way you definitely don't want the [L] on the first rule, as that means "do not apply any subsequent mod_rewrite configuration to this request" –  meulop Feb 22 '12 at 17:36
    
This is an excellent question which I wish would be addressed. It's weird that you can't do this. –  Ezekiel Victor Jul 27 at 17:55

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.