Forum Moderators: phranque

Message Too Old, No Replies

Need help with Mod Rewrite

         

zeeshanhashmi

9:37 am on Dec 14, 2008 (gmt 0)

10+ Year Member



Hello

I have a situation where I have to create a PHP based 2 page website builder engine.

I have almost done that. But here is the thing i need to do.

The file name that is generated through the engine is INDEX.PHP and that have some PHP code in it.

now I want to do the necessary coding in the .htaccess etc, that will treat that index.php file as index.html file.

Another issue is that the INDEX.PHP will have a variable with it means, the links in it are something like this index.php?state=alabama

What i want is that, if a user click on the link for ALABAMA the mod rewrite convert INDEX.PHP?STATE=ALABAMA to ALABAMA.HTML

Please guide !

Thanks
Zeeshan

Mahabub

10:04 am on Dec 14, 2008 (gmt 0)

10+ Year Member



Though I am not good at .htaccess programming but i think the following will be good solution you can try.

RewriteCond %{QUERY_STRING} ^STATE=([^/]+)$
RewriteRule ^INDEX\.PHP$ [yourdomain...]
RewriteRule ^index\.html INDEX.PHP

I am not sure about it perfection. But you may try.

Thanks
Mahabub

[edited by: Mahabub at 10:05 am (utc) on Dec. 14, 2008]

g1smd

5:20 pm on Dec 14, 2008 (gmt 0)

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



You'll need both an internal rewrite and an external redirect as per the examples in the sticky thread at the top of this forum.

The redirect part of the example above is on the right lines, the rewrite part needs completely changing.

jdMorgan

3:37 pm on Dec 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mahabub,

Look into getting rid of those uppercase filenames, URLs, and query string variables. Using uppercase is going to cause you problems in the long term, because almost no-one uses uppercase on the Web. Webmasters and even some search engines are likely to try to link to your pages using lowercase or mixed-case URLs. Therefore, you will probably have to include case-conversion code in your .htaccess, and this is complex, slow, and inefficient.

See my comments in your recent thread [webmasterworld.com] about why the code you posted won't work properly.

Jim

zeeshanhashmi

6:24 pm on Dec 19, 2008 (gmt 0)

10+ Year Member



hi

thanks a lot too all of you participated. Here is what i need.

I will pass these things to index.php

index.php?town=TOWN&state=STATE&pages=pages

now the Rewrite thing should show on the URL this :
Town-State-Pages.html

please guide me how this is possible and also will this help in SEO ?

jdMorgan

6:59 pm on Dec 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See this thread [webmasterworld.com] in our forum library.

Jim

g1smd

8:41 pm on Dec 19, 2008 (gmt 0)

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



See also the comments about Upper Case and Mixed Case URLs.