swg1cor14
swg1cor14

Reputation: 1722

htaccess rewrite rule similar to WordPress

Ok I have a script in the folder 'intake'. The index.php file auto creates a list of urls. Those urls are in the format:

/intake/4/Westrop

I have an .htaccess file in the intake folder. I want it to redirect the url to a FILE.

The above example would then become /intake/redirect.php?id=4&name=Westrop

Here's what I have so far:

DirectoryIndex index.php

Options All -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/(.*)$ /intake/redirect.php?id=$1&name=$2 [L]
</IfModule>

But for some reason if I type /intake or /intake/index.php I get a 404 error. According to firebug its trying to take "intake" and turn it into "intake.php"

Any ideas?

Upvotes: 0

Views: 78

Answers (2)

LazyOne
LazyOne

Reputation: 165298

Place the following code in .htaccess file in website root folder:

RewriteEngine On
RewriteRule ^intake/(\d+)/([a-z0-9\-_]+)$ /intake/redirect.php?id=$1&name=$2 [NC,QSA,L] 

P.S. Do not use this sort of pattern -- ^(.*)/(.*)$ -- in your case for longer URLs it will work not as you would expect. It will match your URL .. but in a wrong way.

Upvotes: 1

anubhava
anubhava

Reputation: 785491

Start your .htaccess with this option:

Options +All -MultiViews -Indexes

Upvotes: 0

Related Questions