Prodigy
Prodigy

Reputation: 380

Add a value to a url with htaccess

I have a big issue here. I have a site example.com, due to the way it was coded, example.com is different from example.com/index. How can i use htaccess to redirect all incoming request from example.com to example.com/index

Here is what i've tried to do but it's not working The first i did was

RewriteRule ^(.*)$ http://%1/index/$1 [R=301,L]

The second was

RewriteRule ^/index/([^/.]+)/?$ index.php [L]

I'm not so familiar with htaccess though. Any help?

Thanks

NOTE there are so many domain the .htaccess file is working for and i want the rule to affect all e.g example.com should go to example.com/index, example1.com should go to example1.com/index and ... like that

And i already have this rule on top RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Upvotes: 0

Views: 50

Answers (2)

anubhava
anubhava

Reputation: 785276

You can use this single rule in the website root .htaccess:

RewriteEngine On

RewriteRule ^/?$ /index [L,R=302]

This will redirect:

example.com => example.com/index
example1.com => example1.com/index

Upvotes: 1

Jon Lauters
Jon Lauters

Reputation: 56

RewriteCond %{HTTP_HOST} =example.com [NC]
RewriteRule ^(.*)$ http://example.com/index.php/$1 [R=301,L]

Upvotes: 1

Related Questions