Marc
Marc

Reputation: 2859

how to redirect with htaccess to a subdirectory but dont show the folder in url (drupal 7)

(There are very similar questions but none of that solved it)

  1. My domain is www.abc.com this is automaticly mapped to /public_html (made by my hoster, i can't change in admin panel)
  2. My cms drupal7.15 is in folder public_html/foo/drupal715/

Big question: WHY: When i open www.abc.com, the url looks www.abc.com/foo/drupal715/index.php It should be the same! BUT the other links or pages i created with drupal are working e.g www.abc.com/myproject

Look at my configuration

I have the first .htaccess in root (public_html) which looks like:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.abc.com$ [OR]
RewriteCond %{HTTP_HOST} ^abc.ch$ [OR]
RewriteRule ^(.*)$ /foo/drupal715/$1 [PT,L,QSA]

This redirects to my sub dir works but why the url shows the folder when i open my main url ?

Any help, please! im so tired of trying.

Here the intresting part of the htaccess in drupal root.

 # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line
  #RewriteBase /foo/drupal715
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  RewriteBase /

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/foo/drupal715/(.*)$
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,B]
  #RewriteRule ^ index.php [L]

best regards

Upvotes: 1

Views: 696

Answers (1)

Germann Arlington
Germann Arlington

Reputation: 3353

The way mod_rewrite works is explained in the docs and discussed many times here too.
It works on the server, it does NOT (unless you specifically make a rule to do this) return any changed urls to the client. This is what allows you to create and use "user friendly urls". If your site redirect from one page/folder to another I would suggest you start looking at what is actually being requested and what it actually does. For example - look at your index.php, what does it do?

Upvotes: 2

Related Questions