Home » Php » .htaccess – How to redirect all urls to url.php except index.php

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

Posted by: admin July 12, 2020 Leave a comment

Questions:
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.

How to&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]

Answer:

This’ll do the trick:

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

Answer:

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.