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
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.