reguller expression issue

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

reguller expression issue

Post by itsmani1 »

Here is my .htaccess code, Its working fine but the problem is i want to optimize it.

Code: Select all

RewriteEngine On
RewriteRule ^contactus contactus.php
RewriteRule ^login login.php
RewriteRule ^signup signup.php
RewriteRule ^selltickets selltickets.php
RewriteRule ^aboutus aboutus.php
i tried to optimized it in this way:

RewriteEngine On
RewriteRule ^(/.*/) $1.php

but did not worked.
any help please
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Hmm... that will be slightly difficult, because a catchall regex would also catch anything you didn't want to rewrite.

Can you cordon off all the scripts into their own little directory? Then:

Code: Select all

RewriteRule ^dir/([a-z]) dir/$1.php
...should do the tirkc.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

won't it work in this way?

Code: Select all

RewriteRule ^/([a-z]+) /$1.php
Last edited by itsmani1 on Thu Nov 23, 2006 8:18 am, edited 1 time in total.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

As long as you don't have anything that is [a-z] in your root directory. Like folders.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

well my requirement is :

http://www.dizyn.com/xxxxx
or
http://www.dizyn.com/xxxxx/


need to be forward at http://www.dizyn.com/xxxxx.php

that's all.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

I tried this, it did not worked. I got flollowing result.

The requested URL /aboutus was not found on this server.

Code: Select all

RewriteRule ^/([a-z]+) /$1.php
Post Reply