Forum Moderators: phranque
then
rewrite it back to the home address (ie. [agent.alpha...]
Is this possible? If so what is the most elegant way to implement it without disrupting future rules. Also, don't know if its relevant or not but, once development is fleshed out the [agent.alpha...] turns into yada yada.com.
thx in advance
You want the shortest possible URL, like domain.com/ or www.domain.com/ and the URL should directly deliver content with a "200 OK" status, not issue a redirect.
I think that you should have a rewrite that pulls the data from the longer filepath when the short URL is requested, and then also have a redirect if the long URL is called, redirecting back to the root URL (a 301 redirect, that is).
Yes that would be ideal, however I'm using the Open-Realty framework which is generating the dynamic content at [domainname.com...]
I don't know how or if its possible to make that dynamic page render at [domainname.com...] --- then I wouldn't need the redirect and rewrite.
So my thinking is when the user goes to the [domainname.com...] redirect them to [domainname.com...] to show them that listing content and then rewrite the URL to a SEF [domainname.com...]
are you saying that doing so would not be good SEO practice?
this is what I'm starting with in my .htaccess
# SEARCH ENINGE FRIENDLY URLS FOR OR 2.0
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>
Options +FollowSymLinks
rewriteEngine On
rewriteBase /
#Rewriterule ^index.html index.php
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 search.html index.php?action=searchpage [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]
# SEO Link for Agent Pages added in Open-Realty 2.4.1
RewriteRule agent-([^-]*)-([0-9]*).html index.php?action=view_user&user=$2 [L]
Can anyone tell me how to implement in a SEF manner?
Thx in advance
Taine
# SEARCH ENINGE FRIENDLY URLS FOR OR 2.0
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>
Options +FollowSymLinks
rewriteEngine On
rewriteBase /
redirect to fix requests for non-canonical domain name
rewriteCond %{HTTP_HOST}!^www\.agent\.alpha
rewriteRule (.*) [agent.alpha...] [R=301,L]
# redirect root to dynamic content
RedirectMatch ^/$ /index.php?action=searchresults [L]
#----------------------------------------------------------#
#Rewriterule ^index.html index.php
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 search.html index.php?action=searchpage [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]
# SEO Link for Agent Pages added in Open-Realty 2.4.1
RewriteRule agent-([^-]*)-([0-9]*).html index.php?action=view_user&user=$2 [L]
EOF
Taine
# redirect root to dynamic content
RedirectMatch ^/$ /index.php?action=searchresults [L]
# rewrite request for root URL-path to internal dynamic-content filepath
RewriteRule ^$ index.php?action=searchresults [L]
RewriteRule ^$ index.php?action=searchresults&pclass[]=1
Your other rules could do with a bit of improvement as well. They will run faster and have less potential to cause unexpected side-effects if they are properly anchored and if literal characters which are also defined as regex tokens within the patterns are properly escaped:
Example:
RewriteRule ^listing-([^-]+)-([0-9]+)\.html$ index.php?action=listingview&listingID=$2 [L]
Jim
This is what a rewrite does. It takes the requested URL and internally translates it into the filepath on the server needed to fetch the content.
The user continues to see the URL they requested, NOT the internal filepath.
>> So my thinking is when the user goes to the domainname.com/ redirect them to domainname.com/index.php?action=searchresults&pclass[]=1&... to show them that listing content and then rewrite the URL to a SEF domainname.com/ <<
You have mixed the terminology up. It should be:
When the user requests www.domainname.com/ rewrite that so that content is pulled from /index.php?action=searchresults&pclass[]=1&... without exposing that information to the user.
If someone requests domainname.com/index.php?action=searchresults&pclass[]=1&..." force an external 301 redirect to domainname.com/ so that the dynamic URL cannot be indexed.
The code for a rewrite and a redirect is very similar. The redirect has an additional [R=301] to force an external redirect.
You'll need a 301 redirect to redirect requests for www.domainname.com/ over to domainname.com/ so that only domainname.com/ can be indexed.