Forum Moderators: phranque

Message Too Old, No Replies

how to 301 permanent redirect dynamic urls?

         

sixeleven

2:40 pm on Aug 19, 2008 (gmt 0)

10+ Year Member



hi

i have urls on my website ,witch accessible with two kind of url

first:

http://www.example.com/p-9.html?osCsid=p9o4u7l7v6m539vvf09j5jrq34

second:

http://www.example.com/p-9.html

how i can make a 301 permanent redirect from first kind to the second?

note:i have too many pages ,witch end with ".html" ,and i dont know the exact name of them ,i just know they end ,by ".html",so i need an formula to redirect all of them

jdMorgan

3:19 pm on Aug 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please see this thread [webmasterworld.com] in our Forum Library to get started.

Jim

sixeleven

6:23 am on Aug 20, 2008 (gmt 0)

10+ Year Member



tanx i read it ,but i have a little confuse in how to use it :(

would you plz help me

g1smd

1:20 pm on Aug 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Post your best effort code here as a basis for discussion.

ag_47

4:38 pm on Aug 20, 2008 (gmt 0)

10+ Year Member



There are tons of other great tutorials all over the web. Look them up if you are having trouble understanding. I'm a beginner too, but it's clear that mod rewrite can only be used if you know what you are doing .. so just search for tutorials, read, understand, and finally give it a shot.

sixeleven

6:02 pm on Aug 20, 2008 (gmt 0)

10+ Year Member



ok,tanx alot

to make a 301 permenent redirect for this type of urls :

http://www.example.com/c-9.html?osCsid=j61lhvng7lvdau2a1enlrku8q0

i add this line :

RedirectMatch 301 (.*)\.html http://www.example.com

but it redirect the pages to none seo urls ,like this :

http://example.com/?cPath=8&osCsid=j61lhvng7lvdau2a1enlrku8q0

and this is my .htaccess witch is suitable for oscmax ,i have install ultimate seo url ,and it will convert ".php" pages to ".html".

/////////////////////////

# The following makes adjustments to the SSL protocol for Internet
# Explorer browsers

<IfModule mod_setenvif.c>
<IfDefine SSL>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</IfDefine>
</IfModule>

# Fix certain PHP values

#</IfModule>

<IfModule mod_php5.c>

php_flag register_globals on

php_flag register_long_arrays on

php_value default_charset UTF-8

</IfModule>

# Ultimate SEO URLs BEGIN
Options +FollowSymLinks
RewriteEngine On
RewriteBase //

RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-(.*).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-(.*).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-(.*).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-i-(.*).html$ information.php?info_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
# Added polls and newsdesk
#RewriteRule ^(.*)-po-([0-9]+).html$ pollbooth.php?pollid=$2&%{QUERY_STRING}
RewriteRule ^(.*)-n-(.*).html$ newsdesk_info.php?newsdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nc-(.*).html$ newsdesk_index.php?newsPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nri-(.*).html$ newsdesk_reviews_info.php?newsdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nra-(.*).html$ newsdesk_reviews_article.php?newsdesk_id=$2&%{QUERY_STRING}
# Ultimate SEO URLs END

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
# ... more RewriteConds ...
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule .* - [F]
</ifModule>

/////////////////////////////

[edited by: jdMorgan at 6:32 pm (utc) on Aug. 20, 2008]
[edit reason] Shortened code dump [/edit]

sixeleven

7:21 am on Aug 24, 2008 (gmt 0)

10+ Year Member



no one can help me ?

how i can remove page title from my url,in .htaccess?
http://www.example.com/page-title-c-9.html

g1smd

4:24 pm on Aug 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



URLs that are indexed are those that appear in the physical links on your pages. That is where URLs are defined.

The rules in .htaccess take *those* URL requests and translate them into the internal server filepath required.