Cases & Power Supplies - Bad Credit Mortgages - Mortgage - Myspace Generators - Bad Credit Mortgages

PDA

View Full Version : Dynamic to Static URL [Mod_rewrite]


ResaleBroker
Oct 1st 2004, 9:48 am
I would like to use a mod_rewrite to change certain dynamic URLs on my site to static.

I have read many of the threads on this topic but none give an example of the rewrite.

I have also searched the web and I couldn't get any of the proposed solutions to work.

An example of my current URL is:
http://www.azmultiplelistingservice.com/listings/listingview.php?listingID=145

I would like it to look something like this:
http://www.azmultiplelistingservice.com/listings/listingview-145

Can anyone help?

expat
Oct 1st 2004, 10:05 am
taken from live site ....nix system

RewriteBase /
RewriteRule ^who-flies-where-(.*)-(.*).htm$ europe-who-flies-where.htm?ww_from=$1&ww_to=$2

changes /europe-who-flies-where.htm?ww_from=lon&ww_to=spain

/who-flies-where-lon-spain.htm

but resolves it to the original so no code change...
M

http://www.departures-arrivals.com/who-flies-where-lon-spain.htm

ResaleBroker
Oct 1st 2004, 10:38 am
Here is my latest attempt.

RewriteEngine on
Options +FollowSymlinks +MultiViews
RewriteBase /
RewriteRule ^listingview.php?listingID=([A-Z0-9]+) listing-$1

DarrenC
Oct 1st 2004, 11:13 am
The setting up of the static html URL is not that difficult, but what I have had problems with in the past is then implementing it on to the website, so that the spiders, and visitors to the website only see the html not php Url's on links etc.

ResaleBroker
Oct 1st 2004, 11:21 am
I don't mind the php URL's. I'm wanting to make the dynamic URL more spider friendly by removing the [?] and the [ID] from the URL.

ResaleBroker
Oct 2nd 2004, 8:10 pm
Still looking for a solution.

Bueler?

Bueler?

ResaleBroker
Oct 4th 2004, 7:16 am
This does it:

RewriteRule ^listingview-([0-9]*).html listingview.php?listingID=$1

awddesign
Oct 4th 2004, 7:31 pm
Hi ResaleBroker

Will have to wait for this one as there is some work to get this to work 100%.

Ah found it

RewriteEngine on
# Redirect internally
# listingview/1/ to listingview.php?listingID=1
# I added the rewrite=yes in the query string
# this is a trick to avoid an infinite loop

RewriteRule ^listingview/([0-9]+)/?$ listingview.php?listingID=$1&rewrite=yes [NC,L]

# remove sessions from site
php_value session.use_trans_sid 0

AddType application/x-httpd-php .html
AddHandler application/x-httpd-php .html

Al

awddesign
Oct 4th 2004, 7:32 pm
Hi

here is another code for you:



#php.ini configuration
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>

php_flag display_errors Off
php_flag register_globals On
php_flag track_vars On

RewriteEngine On

#index
Rewriterule ^index.html index.php

#listingview
RewriteRule ^listingview-([0-9]*).html listingview.php?listingID=$1
RewriteRule ^listingview.html listingview.php
RewriteRule ^listingviewprint-([0-9]*).html listingview.php?listingID=$1&printer_friendly=yes

#listing_browse
RewriteRule ^listing_browse.html listing_browse.php
RewriteRule ^rental_browse.html listing_browse.php?type=Rental

#userview
RewriteRule ^userview.html userview.php
RewriteRule ^userview-([0-9]*).html userview.php?user=$1

#contactus
RewriteRule ^contactus.html contactus.php

#legal
RewriteRule ^legal.html legal.php

#listingsearch
RewriteRule ^listingsearch.html listingsearch.php

#rentalsearch
RewriteRule ^rentalsearch.html rentalsearch.php

#viewusers
RewriteRule ^view_users.html view_users.php

#viewimage
RewriteRule ^viewimage.html viewimage.php
RewriteRule ^viewlistingimage-([0-9]*).html viewimage.php?imageID=$1&type=listing


Al

ResaleBroker
Oct 4th 2004, 8:21 pm
# I added the rewrite=yes in the query string
# this is a trick to avoid an infinite loop
This works: RewriteRule ^listingview-([0-9]*).html listingview.php?listingID=$1&rewrite=yes [NC,L]

This doesn't work: RewriteRule ^listingview/([0-9]+)/?$ listingview.php?listingID=$1&rewrite=yes [NC,L]

Thank You!

ResaleBroker
Oct 4th 2004, 8:28 pm
#php.ini configuration
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>I have this already in my htaccess file as: php_value session.use_trans_sid 0. I'm assuming the <IfModule...etc aren't necessary, right?

php_flag display_errors Off
php_flag track_vars OnMy program is working fine right now. Is this something I should also check? What are these for? They look like something I would find in the php info file but I didn't find them there.

awddesign
Oct 5th 2004, 10:26 pm
Hi

""I have this already in my htaccess file as: php_value session.use_trans_sid 0.""

this code is so the sessions do not show up .

""#php.ini configuration
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>""

this is for if your php.ini does not have it or your cpanel is not setup.

post the link to your site i will check it out for you.

Al

ResaleBroker
Oct 6th 2004, 6:35 am
Hello Al,

The site is http://www.azmultiplelistingservice.com

Thanks!

ResaleBroker
Oct 7th 2004, 4:50 pm
Hi Al,
I saw this over at the OP forum.

Should I be using this too?

setcookie("int", 123, time()+86400*365);
if ($HTTP_COOKIE_VARS[int] == 123)
{
session_start();
}
else if ($_COOKIE[int] == 123) //you can change this but it depends on which version of PHP you have installed as to which one works.
{
session_start();
}
session_register("session");

awddesign
Oct 9th 2004, 8:28 pm
Hi

I not sure what you would want to do with that

Let me know
Al

awddesign
Oct 9th 2004, 8:30 pm
Hi
Of topic :

would you like to add 360 vertual tours to your site ?
Let me know, i can set up a demo area for you.

Al

ResaleBroker
Oct 9th 2004, 8:58 pm
Hi

I not sure what you would want to do with that

Let me know
Al
I just want to make sure there are no Session IDs.

awddesign
Oct 12th 2004, 8:22 am
Hi

Just add this to the .htaccess file

#
php_value session.use_trans_sid 0
#

I think thats what does the trick

Al

ResaleBroker
Oct 13th 2004, 9:36 am
Sound great. Thanks!

awddesign
Dec 27th 2004, 9:30 pm
Hi Jeffrey

I have just looked at your site now with the new
htaccess file, the listings are great.

Will have to do this with all OR's I use

Al

ResaleBroker
Dec 27th 2004, 10:04 pm
It worked out pretty good thanks to all the help.:)