Loans - Free Advertising - Nature's Sunshine - Loans - Credit

PDA

View Full Version : Redirecting Dynamic Page to static page.


joe_mat
Aug 27th 2007, 3:07 am
Hello,

I am having a website where i am having dynamic URL pages in with .php extension.

eg:http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70

i can have redirection code on. .htacces file like

Options +FollowSymLinks
RewriteEngine on


RewriteRule ^category/([0-9]+)]+)/([0-9A-Za-z]+).html$ subcategory.php?subcatID=$1&subname=$2 [L]



and on php page i having have code that create dynamic pages to static pages.

echo "<a href='http://www.".$DOMAIN_NAME."/category/".$rw_sub[0]."/".
format_str(stripslashes($rw_sub[1])).".html'>".$rw_sub[1]."</A></DIV>";



it is creating my dynamic links to static links.
http://www.mydomain.com/category/5/nokia-n70.html

but when i click on that link i didn't find that pages there because i am not having that static html page on that specific static location.

i just wanna know is it possible to have that static pages there without creating them manually.

like if i have dynamic page as :
http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70

and it became static as :
http://www.mydomain.com/category/5/nokia-n70.html

but can i have this static page there without make it manually on that location.

Please suggest.

Thanks

DeViAnThans3
Aug 27th 2007, 12:43 pm
Like you already said, you should use mod_rewrite
http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70
rewrite to
category/5/nokia-n70.html

You already gave the solution yourself; however I'll edit it a bit, maybe it'll work better that way.
Put the following code to your .htaccess file in the root folder (www.mydomain.com).
RewriteEngine on
RewriteRule ^category/([^/\.]+)/([^/\.]+).html?$ subcategory.php?subcatID=$1&subname=$2 [L]

Let's know whether or not it works. Make sure the .htaccess file is only put in the root folder!

joe_mat
Aug 27th 2007, 2:11 pm
Hello,

I have done wht you suggest and that .thaccess and php code make my menu link static from

http://www.mydomain.com/subcategory....name=nokia-n70

to

http://www.mydomain.com/category/5/nokia-n70.html

But when i click on these static link then its show me a blank page with " Page Cannot be

found" error.
because i am not having that static html page on that specific static location.

It is nessecry to create that page nokia-n70.html manually there at specific location

"http://www.mydomain.com/category/5/"

Or it can be happen automaticlly
please suggest

thanks

Like you already said, you should use mod_rewrite
http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70
rewrite to
category/5/nokia-n70.html

You already gave the solution yourself; however I'll edit it a bit, maybe it'll work better that way.
Put the following code to your .htaccess file in the root folder (www.mydomain.com).
RewriteEngine on
RewriteRule ^category/([^/\.]+)/([^/\.]+).html?$ subcategory.php?subcatID=$1&subname=$2 [L]

Let's know whether or not it works. Make sure the .htaccess file is only put in the root folder!

powerspike
Aug 27th 2007, 5:29 pm
RewriteRule ^category/([0-9]+)]+)/([0-9A-Za-z]+).html$ subcategory.php?subcatID=$1&subname=$2 [L]



try


RewriteRule ^category/([0-9]+)/([0-9A-Z]+).html$ subcategory.php?subcatID=$1&subname=$2 [L,NC]


the first () in your rewriterule seemed to have a few extra characters in it