php - Remove any trailing alphanumeric characters from URL -


I have the codeigniter in the website I'm doing to define the rules in the new .htaccess I think that if the customer type At the end of the URL, any alphanumeric character those characters should be stripped OFF

For example:. In

12abc should be removed.

Is there a way to remove a trailing alphanumeric characters by setting up a rule in .htaccess?

I was searching for rewriting rules for the same, but didnt find any flops. Please suggest.

If it's just alphanumeric that you want to remove ...

 < Code> RewriteCond% {RewriteEngine on current REQUEST_FILENAME}! -f RewriteCond% {REQUEST_FILENAME}! -d RewriteRule ^ (([^ /] + /) *) ([One-Z0-9] +) $$ 1 [nc, r = 301, l]  

Two conditions ! -f and ! -d re-write only ensures that the URL does not point to the actual file (or directory) it exists - it prevents the URL that you are actually doing with a specific, Existing file / directory is being rewritten or you are stuck in a horrible recurring loop due to Apache throwing a server error.

This .htaccess file needs to be in the root of your web server, if it is in a sub -directory you will need to add relevant RewriteBase

NC = No Episode (Makes Match Case Sensitive)

R = 301 = This redirects to an actual HTTP 301 redirect So that your URI (removing unwanted characters or digits) will change

L = Last, we have just redirected the rest of the revlight rules without checking


Comments