Jump to content

No Indexes Redirect


Recommended Posts

hmmm.... doesn't seem to work.

 

This is on a sub-domain, and I want to redirect to my "main" domain. The sub-domain has all the images user upload, none of the directories have index files, so if they don't hit a file directly, such as a jpg it needs to redirect them to the main site.

 

I don't know if that helps at all, but the code you gave doesn't redirect me at all (even after changing / to http://mysite.com)

Link to comment
https://forums.phpfreaks.com/topic/240654-no-indexes-redirect/#findComment-1236155
Share on other sites

The second half of the RewriteRule is the path you will be redirected to. In the case of requinix's code / represents document root. If the .htaccess file is on a sub-domain this will refer to the document root of the sub-domain. If you wish to go to the home page of main domain, just swap the forward slash out with your domain name.

 

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ http://www.mysite.com/[L,R]

Link to comment
https://forums.phpfreaks.com/topic/240654-no-indexes-redirect/#findComment-1236176
Share on other sites

It was purely a hypothesis, I'm not entirely surprised it didn't work, though I couldn't tell you the reason, I was just making a suggestion on the solution you'd already tried. You could just check if the requested path ends with a forward slash.

 

RewriteRule /$ http://hostbox.us/ [L,R]

Link to comment
https://forums.phpfreaks.com/topic/240654-no-indexes-redirect/#findComment-1236567
Share on other sites

You could just check if the requested path ends with a forward slash.

Note: this works because Apache will redirect any "dir" request to "dir/" by default. That behavior can be turned off with a DirectorySlash, in which case checking for a trailing slash only works when the users visit "dir/" directly.

Link to comment
https://forums.phpfreaks.com/topic/240654-no-indexes-redirect/#findComment-1236579
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.