简体   繁体   中英

Rewriting a redirected URL with mod_rewrite

Here is my setup :

I have a website located at www.cabsh.org/drupal

I want to use mod_rewrite to do 2 things :

  1. Redirect www.cabsh.org to http://www.cabsh.org/drupal/index.php (I got this one)
  2. Rewrite /www.cabsh.org/drupal/index.php to www.cabsh.org/site/index.php

I cannot figure how to achieve the 2nd point. I'm using .htaccess files since I cannot use the main server configuration. Can anyone help me getting this to work?

Thanks!

From what I get from your comment, you just want something like this:

RewriteEngine on

# Prevent a request directly to the /drupal folder
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/drupal/
RewriteRule ^drupal/(.*)$ /site/$1 [R=301,L]

# Change a request for /site/(anything) to /drupal/(anything)
RewriteRule ^site/(.*)$ /drupal/$1

Be careful though, since Drupal (being in the Drupal folder) might generate links that point to /drupal instead of /site, which is seemingly not what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM