Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess - How to redirect all urls to url.php except index.php

Tags:

php

.htaccess

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    .    url.php    [NC,L]    

I'm redirecting all the requests to url.php but I want to leave index.php as is.

like image 208
kajab Avatar asked Nov 28 '12 16:11

kajab


2 Answers

# Turn On ReWrite Engine
RewriteEngine On

# Exclude url.php and index.php from redirecting
RewriteCond %{REQUEST_URI} !^/(index|url)\.php

# Redirect to url.php
RewriteRule . url.php [NC,L]
like image 177
cryptic ツ Avatar answered Nov 12 '22 00:11

cryptic ツ


This'll do the trick:

RewriteEngine On    # Turnon the rewriting engine
RewriteRule ^/index\.php$ - [L]
RewriteRule    .    url.php    [NC,L] 
like image 21
Ronn0 Avatar answered Nov 12 '22 00:11

Ronn0