kajab
kajab

Reputation: 133

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

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.

Upvotes: 8

Views: 4750

Answers (3)

nathan
nathan

Reputation: 149

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Upvotes: 0

kittycat
kittycat

Reputation: 15044

# 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]

Upvotes: 7

Ronn0
Ronn0

Reputation: 2269

This'll do the trick:

RewriteEngine On    # Turnon the rewriting engine
RewriteRule ^/index\.php$ - [L]
RewriteRule    .    url.php    [NC,L] 

Upvotes: 2

Related Questions