Atomix
Atomix

Reputation: 2500

Mod_rewrite all request to subdirectory

I want to redirect all of the requests to my website www.example.com/page.php to www.example.com/1/page.php (where page.php is any page request), but I am new to mod_rewrite and cannot figure out how to do this.

What would be the rewrite_rule and/or conditions to do this?

Upvotes: 0

Views: 2946

Answers (2)

Ian Wood
Ian Wood

Reputation: 6573

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^page.php$ 1/page.php [NC,L]

this can go in your htaccess file but will only redirect requests to page.php

Upvotes: 0

RusAlex
RusAlex

Reputation: 8575

try this

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

I didn't test it, but it must work

Upvotes: 1

Related Questions