homepage Welcome to WebmasterWorld Guest from 54.161.247.22
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
links change depending on page they appear on
joergnw10




msg:3669809
 2:18 pm on Jun 8, 2008 (gmt 0)

I moved my site to an open source cms last night and have been having trouble with my .htaccess. The last problem I am aware of, and that I can't seem to solve, is that 'listings' change their url depending on which page they are linked from. For example 'listing-house-london-12' should always be www.example.com/listing-house-london-12.html. But when I hardcode a search onto a page like example.com/property/houses.html the link in the search results changes to /property/listing-house-london-12.html

Please see below the main part of the .htaccess. Is there something obvious that might need changing? Thanks in advance!

# SEARCH ENINGE FRIENDLY URLS
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(php¦html?)\ HTTP/
RewriteRule ^([^/]+/)*index\.(php¦html?)$ http://www.example.com/$1 [R=301,L]
#

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301.L]
#
RewriteRule listing-(.*?)-([0-9]*).html index.php?action=listingview&listingID=$2 [L]
RewriteRule page-(.*?)-([0-9]*).html index.php?action=page_display&PageID=$2 [L]
RewriteRule searchresults.html index.php?action=searchresults [L]
RewriteRule agents.html index.php?action=view_users [L]
RewriteRule view_favorites.html index.php?action=view_favorites [L]
RewriteRule calculator.html index.php?action=calculator&popup=yes [L]
RewriteRule saved_searches.html index.php?action=view_saved_searches [L]
RewriteRule listing_image_([0-9]*).html index.php?action=view_listing_image&image_id=$1 [L]
RewriteRule logout.html index.php?action=logout [L]
RewriteRule member_signup.html index.php?action=signup&type=member [L]
RewriteRule agent_signup.html index.php?action=signup&type=agent [L]
RewriteRule member_login.html index.php?action=member_login [L]
RewriteRule edit_profile_([0-9]*).html index.php?action=edit_profile&user_id=$1 [L]
RewriteRule agent-([^-]*)-([0-9]*).html index.php?action=view_user&user=$2 [L]


 

jdMorgan




msg:3669852
 4:43 pm on Jun 8, 2008 (gmt 0)

Your rules are ambiguous, since they do not use start anchors, but that is not the likely problem. Rather, it seems that your expectations about what mod_rewrite does, and when it does it are not correct.

mod_rewrite acts *after* a user clicks on one of your links, sending an HTTP request to your server. Mod_rewrite receives this request, and can do one of several things. The most common actions are to internally rewrite the request to a different file path that what would be expected if the rewrite was not present, or to generate an external redirect to tell the browser to ask for the requested resource again, using a different URL.

Mod_rewrite cannot change the links that appear on your CMS-generated pages -- only your CMS can do that.

You'll need to modify your CMS to produce the correct URLs, and then mod_rewrite will rewrite them, when they are received from the client, to your "index.php" script.

For more information on the client-server transaction, and when and how mod_rewrite comes into play, see this thread, "Changing Dynamic URLs to Static URLs [webmasterworld.com]."

Additional information is available in our Forum Charter, and in the Apache forum Library -- See links at top of this page.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved