Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

some URL rewrites get visible

Status
Not open for further replies.

Olaf Doschke

Programmer
Oct 13, 2004
14,847
DE
The general URL schema of a site is

So I made these Rewrite Rules via .htaccess in the dir which is mapped to the dev.domain.com subdomain.
Code:
RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^$    controller.php  [NC,L] #handle requests into the root domain
RewriteRule    ^([a-z]+)/?$    controller.php?lang=$1 [NC,L] #handle requests with specified language
RewriteRule    ^([a-z]+)/([a-z]+)/?$    controller.php?lang=$1&detail=$2 [NC,L] #handle requests with specified language and detail page

It works with one slight quirk:
Specifying just without slash in a browser the URL rewrite gets (partially) visible in the browser URL field as This does not happen when the URL entered into the browser is with the final slash.

This is not browser dependent, so it should be apache.

The same behaviour does not happen with vs . In that case the third rewrite rule is triggered and the parameterization does not get visible.

What's going on here? And could these rewrite rules perhaps be simplified into one rule only?

Bye, Olaf.
 
The problem reported is not reproducible and must have been a browser cache issue resolved by expiration.

Anyway, I finally came up with these conditions & rules:
Code:
RewriteEngine On    # Turn on the rewriting engine

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^mydomain.com\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://[URL unfurl="true"]www.mydomain.com%{REQUEST_URI}[/URL] [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$        /$1$2/ [R=301,L]

RewriteRule ^$                    controller.php  [NC,L] #handle requests into the root domain
RewriteRule ^([a-z]+)/$           controller.php?lang=$1 [NC,L] #handle requests with specified language
RewriteRule ^([a-z]+)/([a-z]+)/$  controller.php?lang=$1&detail=$2 [NC,L] #handle requests with specified language and detail page

This does redirect any request of mydomain.com to it redirects https and http requests, in the second level it also adds a trailing slash for non file requests both these things are done with a 301 redirect. Finally the rules I already had are applied as simple rewrite, no redirect, just changed to requiring the final slash.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top