Forum Moderators: phranque

Message Too Old, No Replies

how to make this links Rewrite

rewrite

         

zeal2008

4:47 am on Nov 10, 2008 (gmt 0)

10+ Year Member



hi all

i have a web site and i want to make it work with Rewrite

how can i make this pages Rewrite

http://www.example.com/video/php?pt=feature
to be : http://www.example.com/feature

http://www.example.com/video/submit.php?pt=submit&part=1
to be : http://www.example.com/submit

http://www.example.com/video/index.php?pt=all
to be : http://www.example.com/all

http://www.example.com/video/categories.php?pt=categories
to be : http://www.example.com/categories

http://www.example.com/video/images.php?pt=images
to be : http://www.example.com/images

i have trying something on my .htaccess


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([0-9a-zA-Z-]+)\,([0-9a-zA-Z-]+)\$ php?pt=feature

Help me pls

thx

[edited by: jdMorgan at 3:27 pm (utc) on Nov. 10, 2008]
[edit reason] example.com [/edit]

jdMorgan

3:34 pm on Nov 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In example.com/.htaccess:

Options +FollowSymlinks
RewriteEngine on
#
RewriteRule ^feature$ /video/php?pt=feature [L]
RewriteRule ^submit$ /video/submit.php?pt=submit&part=1 [L]
RewriteRule ^all$ /video/index.php?pt=all [L]
RewriteRule ^(categories¦images)$ /video/$1.php?pt=$1 [L]

The first requirement (for the "feature" page) does not look correct, because the "script" filename appears to be just "php", and not "feature.php" or "index.php". However I coded it to meet the stated requirement.

The last rule handles both "categories" and "images". Change the broken pipe "¦" character to a solid pipe character before use.

This code is one of two or three steps you must take. The next step is to change the links on your pages to refer to "/feature", "/submit", etc. instead of linking to the old dynamic URLs. This can be done either by ediring your database, or perhaps using php's "preg_replace" directive in the php code itself.

A third optional step is to redirect direct client requests for the old dynamic URLs back to the new static URLs. Get the first two steps working first before trying to do this, though. This step is tricky in that you must use a RewriteCond to check %{THE_REQUEST} to be sure that the dynamic URL is being requested by a client, and not a result of a previously-executed internal rewrite. It's a little complicated, but this final step prevents duplicate content issues, and speeds up the search engines' indexing of your new URLs.

Jim

g1smd

5:34 pm on Nov 10, 2008 (gmt 0)

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



As confirmation of that final comment, a site migrated to new URLs only two weeks ago is already 90% showing under the new URLs in Google. The old URLs do redirect to the new format, and many of the old URLs now show as Supplemental Results - bringing additional traffic wherever they still show in SERPs.

zeal2008

3:14 am on Nov 11, 2008 (gmt 0)

10+ Year Member



thx jdMorgan and g1smd for your reply

jdMorgan your code not work for me


Options +FollowSymlinks
RewriteEngine on
#
RewriteRule ^feature$ /video/php?pt=feature [L]
RewriteRule ^submit$ /video/submit.php?pt=submit&part=1 [L]
RewriteRule ^all$ /video/index.php?pt=all [L]
RewriteRule ^(categories¦images)$ /video/$1.php?pt=$1 [L]

i change video TO chaabi
but code didnt work

i use .htaccess on folder example.com/chaabi/
index.php
submit.php
images.php
categories.php
videos.php


Options +FollowSymlinks
RewriteEngine on
#
RewriteRule ^([0-9a-zA-Z-]+)\,([0-9a-zA-Z-]+)\.html$ videos.php?id=$2&url=$1
RewriteRule ^feature$ /chaabi/php?pt=feature [L]
RewriteRule ^submit$ /chaabi/submit.php?pt=submit&part=1 [L]
RewriteRule ^all$ /chaabi/index.php?pt=all [L]
RewriteRule ^(categories¦images)$ /chaabi/$1.php?pt=$1 [L]

index.php
submit.php
images.php
categories.php

my web site http://example.com/chaabi/index.php

i am so sorry my english not good

[edited by: jdMorgan at 12:55 pm (utc) on Nov. 11, 2008]
[edit reason] No URLs, please. Use example.com [/edit]

jdMorgan

1:02 pm on Nov 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The modifications you made appear to be correct for use in /chaabi/.htaccess

If you type the URL http://example.com/chaabi/all into your browser, then you should see the page generated by your script at /chaabi/index.php?pt=all

So, how did you test?
What were the results?
How did the results differ from your expectations?

Again, for this to work, you must change the links on your pages to use the SEO-friendly "http://example.com/chaabi/all" format, you must change the broken pipe "¦" characters in the code to solid pipe characters, and you must completely flush your browser cache before testing any new code on your server.

Jim