News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Htaccess Redirect

Started by glennk, March 13, 2014, 02:18:36 PM

Previous topic - Next topic

glennk

Hi guys, I would like to redirect with a 301

From

http://www.whitbyseaanglers.co.uk/forum/index.php?action=tags;tagid=1765

To

http://www.whitbyseaanglers.co.uk/forum/index.php

Cany you advise on the coed and if the htacess goes in root or goes in the forum folder.

kat

Redirect /index.php?action=tags;tagid=1765 http://www.whitbyseaanglers.co.uk/forum/index.php

Might work.

But, I suspect you might get other cockups, if you do that.

Worth a try?

glennk

Hi Mate, I tried that and it never did anything at all. Can anyone else make a suggestion ??

Also where does the Htaccess file go ?? Is it in the root folder or the forums sub folder.

kat

I'd assume in whatever directory you have the forum in.

Chen Zhen

glennk,

../forum/.htaccess

Options All -Indexes
Options +FollowSymLinks -MultiViews
ErrorDocument 301 http://www.whitbyseaanglers.co.uk/forum/error.html
RewriteEngine on
RewriteCond %{QUERY_STRING} ^action=tags;tagid=1765$
RewriteRule ^index.php$ index.php [NC,R=301,L]


Create a custom error message within a new file named error.html and place it in your forum directory.

../forum/error.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Page Not Found</title>
<body>

<h2>We're sorry but the page you're looking for could not be found</h2>
<div>&nbsp;</div>
<div><a href="http://www.whitbyseaanglers.co.uk/forum">Go back to the Home Page</a></div>
</body>
</html>


Regards.

My SMF Mods & Plug-Ins

WebDev

"Either you repeat the same conventional doctrines everybody is saying, or else you say something true, and it will sound like it's from Neptune." - Noam Chomsky

Chen Zhen

glennk,

  I am not sure if the options that I included allow access to something they should not although I do not think so as everything was open to a certain extent without the file. However, I will show you another .htaccess example with some extra rules including the same redirect for a 404 error and some restrictions to file types. These file rules should only apply when someone attempts to access them directly via the url.


../forum/.htaccess

Options All -Indexes
Options +FollowSymLinks -MultiViews
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Files *.txt>
order allow,deny
deny from all
</Files>
RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml
ErrorDocument 301 http://www.whitbyseaanglers.co.uk/forum/error.html
ErrorDocument 404 http://www.whitbyseaanglers.co.uk/forum/error.html
RewriteEngine on
RewriteCond %{QUERY_STRING} ^action=tags;tagid=1765$
RewriteRule ^index.php$ index.php [NC,R=301,L]


  Someone else on this forum more experienced with .htaccess rules may provide edits to the above but Imo this may be satisfactory for the purpose outlined in your first post.

Regards.

My SMF Mods & Plug-Ins

WebDev

"Either you repeat the same conventional doctrines everybody is saying, or else you say something true, and it will sound like it's from Neptune." - Noam Chomsky


glennk

Also I tried both suggestions and nothing happens. Im wondering why I cant redirect ??

mashby

Wonder if K@'s suggestion just needs a little tweak?
Redirect /forum/index.php?action=tags;tagid=1765 http://www.whitbyseaanglers.co.uk/forum/index.php
Always be a little kinder than necessary.
- James M. Barrie

glennk

Quote from: mashby on March 24, 2014, 11:16:10 PM
Wonder if K@'s suggestion just needs a little tweak?
Redirect /forum/index.php?action=tags;tagid=1765 http://www.whitbyseaanglers.co.uk/forum/index.php

Is this the only line I need as Ive already tried that on its own, or is there extra code with it ?

Advertisement: