Jump to content

mod_rewrite and regexpression with dot


commentator

Recommended Posts

Hi,

 

I'm trying to rewrite everything on my domain to a php file

 

RewriteRule ^([A-Za-z_0-9/]+)$ file.php/$1

 

this is working for directories now:

 

so http://my.dom.ain/dir1/dir2/ is redirected to file.php/dir1/dir2/

 

I want to use this also for files.

 

like:

http://my.dom.ain/dir1/dir2/file1.ext

http://my.dom.ain/dir1/file9.ext

 

 

When adding a dot like:

RewriteRule ^([A-Za-z_0-9/.]+)$ file.php/$1

or

RewriteRule ^([A-Za-z_0-9/\.]+)$ file.php/$1

 

it doesn't work. Anyone here knowing how to fix this?

Link to comment
https://forums.phpfreaks.com/topic/60393-mod_rewrite-and-regexpression-with-dot/
Share on other sites

Not sure what you want to do, and I didn't test it.

 

...

 

this is working for directories now:

 

so http://my.dom.ain/dir1/dir2/ is redirected to file.php/dir1/dir2/

 

I want to use this also for files.

 

like:

http://my.dom.ain/dir1/dir2/file1.ext

http://my.dom.ain/dir1/file9.ext

...

Dude, why are you copying the same question you're asking?

I did read your first post, but I still don't understand, you should be giving more details example of what you're asking.

 

Simply, I know how your file.php works, but you can try this,

RewriteRule ^([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)?/?([a-zA-Z0-9-_]+)(\.[a-zA-Z0-9]+)$ file.php?dir=$1&dir2=$2&$file=$3&ext=$4

well it's very simple what I want, just to have everything in this $1 behind the file

RewriteRule ^([A-Za-z_0-9/]+)$ file.php/$1

 

The script checks the dirs and expects just everything behind the / behind file.php/

 

For dirs it is already working:

my.domain/dir1/dir2/

my.domain/dir1/dir2/dir3/

my.domain/dir1/dir2/dir4/dir5/dir6/

 

al these dirs are now in the $1

 

but I want to use this also for files

 

my.domain/dir1/dir2/file1.ext

my.domain/dir1/dir2/dir3/file98098.ext

my.domain/dir1/dir2/dir4/dir5/dir6/file5456416546.ext

 

I want the dirs above like:

file.php/my.domain/dir1/dir2/file1.ext

file.php/my.domain/dir1/dir2/dir3/file98098.ext

file.php/dir1/dir2/dir4/dir5/dir6/file5456416546.ext

 

all I need to know is how to add the . in this rule like the / that works already

RewriteRule ^([A-Za-z_0-9/]+)$ file.php/$1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.