Pars
Pars

Reputation: 5262

Redirect all pages to /index.php file

I know there are plenty of tutorials about redirecting all pages to a specific domain/index.php or html page.
But I need to redirect all my pages to a ServerIP/myDirectory/ProjectName/index.php
because I work in an office which shares it's wamp to clients. so in my computer I need to go to my directory on local server and then using server's wamp.

example URL : http://192.168.0.100/myDirectory/ePortal/index.php

How can I do that? I have this in my htaccess file.

RewriteBase /myDirectory/ePortal/
RewriteRule .* index.php

But this htaccess is wrong. 500 Internal Error appears.

Upvotes: 0

Views: 1894

Answers (2)

andy
andy

Reputation: 2399

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$/? index.php?url=$1 [PT,L]

</IfModule>

This checks that the file doesn't exist before redirecting. That was, static paths still work :)

Upvotes: 0

jacouh
jacouh

Reputation: 8741

You can try this:

# URLs not to redirect:
RewriteRule ^/?(captcha|My-Another-Url-Not-To-Redirect)\.php$ - [L]

# redirect all others:
RewriteRule ^/.* http://192.168.0.100/myDirectory/ePortal/index.php [L,R]

# or you may want only to redirect the homepage, then comment line above, put this:
#RewriteRule ^/index\.php http://192.168.0.100/myDirectory/ePortal/index.php [L,R]

Upvotes: 2

Related Questions