INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

some URL rewrites get visible

some URL rewrites get visible

(OP)
The general URL schema of a site is
http://dev.domain.com/lang/page

So I made these Rewrite Rules via .htaccess in the dir wwwroot/dev/ 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 http://dev.domain.com/en without slash in a browser the URL rewrite gets (partially) visible in the browser URL field as http://dev.domain.com/en/?lang=en
This does not happen when the URL entered into the browser is http://dev.domain.com/en/ with the final slash.

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

The same behaviour does not happen with http://dev.domain.com/en/home vs http://dev.domain.com/en/home/. 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.

RE: some URL rewrites get visible

(OP)
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://www.mydomain.com%{REQUEST_URI} [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 www.mydomain.com, 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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close