TransWikia.com

Apache simple redirect not working

Server Fault Asked by cma4 on December 25, 2021

I’m trying to redirect all requests from my website to a subdir but it doesn’t work. This thing is going to make me crazy and any help would be appreciate.

In conclusion, I want this :

to

Here is my rule :

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/mydir/$

RewriteRule ^(.*)$ /mydir/

But it doesn’t work… Apache doesn’t redirect. What am I doing wrong??

Thank you,

Regards.

One Answer

First make sure .htaccess and mod_rewrite are working. If .htaccess is not enabled, add AllowOverride All to Apache configuration file to enable .htaccess

For redirecting test

RewriteEngine On RewriteRule ^/?test/(.*)$ /mydir/$1 [R,L]

or for everything

RewriteEngine On RewriteRule ^(.*)$ /mydir/$1 [R,L]

Answered by Ameer Iqbal on December 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP