Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-20-2009, 01:36 PM   PM User | #1
ravonet
New to the CF scene

 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ravonet is an unknown quantity at this point
.htaccess - 301 SEO redirect on single pages

I have the following .htaccess for my CMS Made Simple web site.

Now I want to move some articles from my article-section on the web site to my blog - therefore I would like to do something like this:

redirect 301 http://www.mydomain.com/articles/my-article http://www.mydomain.com/blog/my-article

But this does not work with my .htaccess - any idea why? - or how to solve the problem?

Mydomain.com - is a CMS Made Simple web site
Mydomain.com/blog - is a WordPress blog

I really hope someone can tell me how to do redirects on single pages that I have to move and still use this .htaccess

***************************************************
Here is my .htaccess
***************************************************

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} ^mydomain.dk
RewriteRule (.*) http://www.mydomain.dk/$1 [R=301,L]


# URL Filtering helps stop some hack attempts
#IF the URI contains a "http:"

RewriteCond %{QUERY_STRING} http\: [OR]

#OR if the URI contains a "["

RewriteCond %{QUERY_STRING} \[ [OR]

#OR if the URI contains a "]"

RewriteCond %{QUERY_STRING} \] [OR]

#OR if the URI contains a "<script>"

RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]

#OR script trying to set a PHP GLOBALS variable via URL

RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

#OR any script trying to modify a _REQUEST variable via URL

RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^.*$ - [F,L]

# END Filtering

# CMSMS Rewriting - Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
# Set assume mod_rewrite to true in config.php and clear CMSMS cache

RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]

**************
Thanks in advance
ravonet is offline   Reply With Quote
Old 05-20-2009, 06:29 PM   PM User | #2
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
Redirect with mod_rewrite
Code:
RewriteRule ^old$ http://www.mydomain.com/new [R=301,L]
Code:
Options +FollowSymLinks

RewriteEngine On

# Redirects.
RewriteRule ^articles/my-article/?$ http://www.mydomain.com/blog/my-article [R=301,L]

# 301 Redirect all requests that aren't a file to
# include a trailing slash
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ http://www.example.dk%{REQUEST_URI}/ [R=301,L]

# Force www.
RewriteCond %{HTTP_HOST} ^(example\.dk)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

# URL Filtering helps stop some hack attempts
RewriteCond %{QUERY_STRING} (http\:|\[|\]) [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|_REQUEST)(=|\[|\%[0-9A-Z]{0,2}) [NC]
RewriteRule .* - [F,L]
# END Filtering

# CMSMS Rewriting - Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
# Set assume mod_rewrite to true in config.php and clear CMSMS cache
RewriteCond %{SCRIPT_FILENAME} !-f [NC]
RewriteCond %{SCRIPT_FILENAME} !-d [NC]
RewriteRule ^(.+)$ /index.php?page=$1 [QSA,L]
schleppel is offline   Reply With Quote
Reply

Bookmarks

Tags
.htaccess, 301, redirect, seo

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:43 AM.


Advertisement
Log in to turn off these ads.