0

OK so I've found every rendition of this but not this specifically. So my urls are in this format

www.inspection.com/users/?action=register

I want to convert it to

www.inspection.com/users.php?action=register

Here's what I've got so far in my htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^[A-Za-z0-9]+/\?action=[A-Za-z0-9]+$ $1.php?action=$2 [L,QSA]

But error logs say RewriteRule: cannot compile regular expression

Main Goal: After the domain name is the reference to the file I want to call. So append php on the end of that string but keep the query parameters

1 Answer 1

1

With your shown samples, attempts please try following .htaccess rules file. Please make sure to clear your browser cache before testing your URLs. Also make sure that your .htaccess rules file and .php file are residing on same folder.

RewriteEngine ON

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/?]*)/?\?action=(.+)$ $1.php?action=$2 [NC,L,QSA]

One more thing, you have not created a capturing group on left side of RewriteRule hence you can't use them on the right side of it.

Sign up to request clarification or add additional context in comments.

2 Comments

@swg1cor14, please make sure to clear your browser cache before testing your URLs.
Please explain your regex to make it easier to understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.