473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

.htaccess - regex syntax is correct but still internal error

n8kindt
221 100+
i'm trying to allow my website to use a http://ourdomain.com/fname.lname/ format. i am fairly certain my regex syntax is correct. here's what i have:


Expand|Select|Wrap|Line Numbers
  1. <IfModule mod_rewrite.c>
  2.     RewriteEngine on
  3.         RewriteCond   %{REQUEST_URI}   \/.+\.?.+\/*$    [NC]
  4.     RewriteRule ^(.*)$ /index.php?path=$1 [L,QSA]
  5. </IfModule>
the weird thing is i can get the above to work by replacing the rewrite with:
RewriteCond %{REQUEST_URI} \/.?\.?.?\/*$ [NC]
(replacing the two "+" with two "?")

unfortunately, i have no interest in using the http://www.ourdomain.com/f.n/ format

anybody have any clue why this is happening?
Sep 27 '08 #1
4 3850
Atli
5,058 Expert 4TB
Hi.

I tried this, and it worked on my server (Apache/2.2.8).

I did see one problem tho. Your regex seemed to match any string rather then just your "firstname.lastname" scenario.

It should look a bit more like this:
Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{REQUEST_URI} .+?\..+?/*$ [NC]
  2. RewriteRule ^(.+?)\.(.+?)/*$ index.php?first=$1&last=$2 [L,QSA]
  3.  
Note that I removed the / in front of the index.php in the Rule so I could test this in a sub-directory.

By itself, this gives a 404 error if the URL isn't formatted like you showed above.

This isn't perfect tho. Because you used the dot class the name can contain all sorts of weird characters. You may want to specify a more limited range of characters.
Oct 1 '08 #2
n8kindt
221 100+
Hi.

I tried this, and it worked on my server (Apache/2.2.8).

I did see one problem tho. Your regex seemed to match any string rather then just your "firstname.lastname" scenario.

It should look a bit more like this:
Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{REQUEST_URI} .+?\..+?/*$ [NC]
  2. RewriteRule ^(.+?)\.(.+?)/*$ index.php?first=$1&last=$2 [L,QSA]
  3.  
Note that I removed the / in front of the index.php in the Rule so I could test this in a sub-directory.

By itself, this gives a 404 error if the URL isn't formatted like you showed above.

This isn't perfect tho. Because you used the dot class the name can contain all sorts of weird characters. You may want to specify a more limited range of characters.
wow, i really like how you improved on my idea and improved the syntax. i will test it out later tonite. thank you so much!!
Oct 1 '08 #3
n8kindt
221 100+
oh boy. after testing it for about a half hour with the same 500 error returning, i decided to try it on another domain i have access to that is hosted by a completely different company. wouldn't you know, it worked. so the syntax is obviously not the problem. it is so wierd that it trips on more than one ".+" in the regex.

is there some kind of setting that might be tweaked on my site causing the error? i also found out that the site in question is running an ancient Apache/1.3.41. not the first time this host has been behind the times. might have to give up yet another project due to dark aged hosting sites...
Oct 2 '08 #4
n8kindt
221 100+
still struggling with this. suggestions anyone?
Nov 18 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ivo | last post by:
Greetings newsgroup, I am moving some php scripts to a new host. While getting to know the server, I ran into a strange problem. If I add a .htaccess file, or more specifically: a .htaccess with...
3
by: Adam King | last post by:
Hey, I've done the standard old trick of adding the error page line into ..htaccess which works absolutely fine if I accidently go to any file other than .php But if I go to "doesntexist.php" I...
15
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
3
by: jg | last post by:
I made a mistake somewhere in my vb code and I look, check and read against the articles and help on regex, I still can't find the mistake I made. I know my test string and the test patterns...
2
by: jaanus | last post by:
Here we go... What I have been trying to do is to forward all http requests containing /cms/ to http://cms.mydomain.com/ example1: http://host1.mydomain.com/cms/init.php would be parsed from...
1
by: Sean128 | last post by:
Hi, I hope someone can help me - this seems like it should be a really simple problem but I've been having trouble trying to solve it all week. I have hosted my website on a Linux server in 1...
1
by: dominoeffect | last post by:
Hi all, I (hastily) updated my .htaccess to include this 3G blacklist which blocks scrapers, hackers and the like. perishablepress.com/press/2008/05/13/perishable-press-3g-blacklist/ ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.