.htaccess for PDF URL .htaccess for PDF URL apache apache

.htaccess for PDF URL


Welcome to StackOverFlow, try this:

RewriteEngine OnRewriteBase /RewriteRule ^pdf/([a-z0-9\-_\.]+)$ pdf.php?file=$1 [L,NC,QSA]RewriteCond %{REQUEST_URI} !^/pdfRewriteRule ^([a-z0-9\-_\.]+)/?$ index.php?page=$1.html [L,NC,QSA]

L: The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl, or the break command in C. Use this flag to indicate that the current rule should be applied immediately without considering further rules.

QSA : When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

NC: Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI.

Also, I would recommend to use dashes instead of underscore.