the_man_slim
the_man_slim

Reputation: 1215

Mod_rewrite doesn't seem to work for this rewrite rule

I'm trying to set up a simple rewrite rule so that something like

mysite.com/admin

becomes

mysite.com/new/admin

I have tried the following :

RewriteEngine On
RewriteRule ^admin.*  new/admin [L]

But that doesn't seem to be working. It just results in a 404 error, which is the same as what I was getting before. My logs don't seem to show anything. Here is my configuration file:

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName mysite.com
  DocumentRoot /var/www

  <Directory />

   Options FollowSymLinks
   AllowOverride None
  </Directory>
  <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
  </Directory>

If anyone knows the proper rewrite rule to settle this, that would be most excellent!

Upvotes: 0

Views: 560

Answers (2)

poncha
poncha

Reputation: 7856

Try this:

RewriteEngine On
RewriteBase /
RewriteRule ^admin(.*) new/admin$1 [L,R,QSA]

Flags explanation:

  • L - last rule (processing will stop at that point)
  • R - redirect (without this flag, apache will do sub-request and will still show the original URL to the browser)
  • QSA - append the original query-string

Upvotes: 2

user1452132
user1452132

Reputation: 1768

Can you please try the following with the slash..

RewriteRule ^admin.* /new/admin [L]

Upvotes: 0

Related Questions