1

I found several topics related to my problem on stackoverflow.com, but I have not found the solution yet.

This is my .htaccess code :

RewriteEngine On
RewriteRule ^library-(.*)\.aspx$ index.php?page=library&image=$1 [NC,L,QSA]
RewriteRule ^information-(.*)\.aspx$ index.php?page=information&text=$1[NC,L,QSA]

Great, the new formatting of URLs works :

https://example.com/library-image5000.aspx or https://example.com/information-sometext.aspx

But, can anyone tell me why the url accept the both of query strings?

https://example.com/library-image5000.aspx/information-sometext.aspx

1 Answer 1

1

This is because your regex pattern ^library-(.*)\.aspx$ also matches the URI /library-image5000.aspx/information-sometext.aspx .

You can use use a restricted pattern instead of the catch-all (.*) . Use ([^/]+)as it matches any characters except / .

RewriteEngine On
RewriteRule ^library-([^/]+)\.aspx$ index.php?page=library&image=$1 [NC,L,QSA]
RewriteRule ^information-([^/]+)\.aspx$ index.php?page=information&text=$1[NC,L,QSA]
Sign up to request clarification or add additional context in comments.

Comments

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.