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.

There are a lot of apache / mod_rewrite questions here, and I looked at them but didn't find a duplicate.

I have a web site properly running with apache, mod_rewrite and fast cgi.

.htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ script_fcgi/$1 [L,QSA]
</IfModule>

This way, it works as expected. When requesting example.com/my_path, 'my_path' is properly passed to the script.

The problem is that the exact same path is also accessible at example.com/script_fcgi/my_path

I'd like to redirect the longer URL to the shorter one. The following does not seem to work:

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteRule ^/script_fcgi(.*)$ $1 [R]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ script_fcgi/$1 [L,QSA]
</IfModule>

It seems the rewrite rule is not being processed because it already maps to the path to the script.

share|improve this question
    
Why did you want a request to /script_fcgi/my_path will be redirect to /my_path and after that redirect back to /script_fcgi/my_path? –  quanta Oct 2 '11 at 13:51
    
The second rewrite rule is necessary so that the proper script handler is called. This is done server side and the user is none the wiser. The first rewrite rule is just in case the user accesses the path with the actual script handler, in order to redirect to the shorter URL (as written in the browser location bar). –  augustin Oct 2 '11 at 14:23
add comment

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.