i want to write .htaccess whcih pass 5 letters to the page as variable
those 5 letters are (small alphabets & numbers only)
For example if someone goto http://www.abc.com/etd01 i want to pass etd01 to http://www.abc.com/link.php?link=etd01
so i wrote
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ LinkCode.php?LinkCode=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ LinkCode.php?LinkCode=$1
it is working but if some open http://www.abc.com/dswdrd then also it is passing the variable.
what i want is if length is 5 they pass otherwise do nothing
is it possible??
no i have change my .htaccess file to
RewriteEngine On
RewriteRule ^([a-z0-9]{5})/?$ LinkCode.php?LinkCode=$1
but now when i place
RewriteRule ^([a-z0-9]{5})/?$ LinkCode.php?LinkCode=$1
at the end of joomla .htaccess file it doesnt work
joomla .htaccess file is below
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
RewriteRule ^([a-z0-9]{5})/?$ LinkCode.php?LinkCode=$1
<Files ~ "\.vcf$">
ForceType text/x-vcard
</Files>
1) You have
+, which means 1 or more. If you want 5 exactly, replace it by{5}.2) You said you want “(small alphabets & numbers only)”, but your template will ALSO match capital letters as well as minus
-and underscore_. I have removed them from pattern to match your requirement.3) I’ve also joined 2 rules into 1 (will handle URL with and without trailing slash).