开发者

Creating pretty url's with htaccess

开发者 https://www.devze.com 2023-03-20 01:25 出处:网络
After doing a couple hours of resear开发者_如何学编程ch, I found out that there are multiple KINDS of htaccess files.

After doing a couple hours of resear开发者_如何学编程ch, I found out that there are multiple KINDS of htaccess files.

So i have a three part question

(A)What kind of htaccess file do I have?

(B)Is this the correct way of trying to rewrite the files?

(C)Is there a way to close an htaccess file? For instance if you start a php doc, you start with <?php and end with ;?> and with an html doc you start with <html> and end with </html>. How would you close an htaccess file?

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.home*)$ index.php [L,QSA]
RewriteRule ^(.settings*)$ edit_profile.php [L,QSA]
RewriteRule ^(.in*)$ pm.php [L,QSA]
RewriteRule ^(.seed*)$ seed.php [L,QSA]


A) There is only one kind of .htaccess file. Apache configuration settings can either be in the central configuration (apache2.conf etc.), or .htaccess files. The advantage of the latter is that you don't have to restart the server.

B) That depends on what you want to do.

C) It's not necessary to close a .htaccess file, it's just a file containing a bunch of lines.


By kinds of htaccess files, do you mean files that begin with .ht? As far as I know there are .htaccess files which are used for configuration purposes, and .htpasswd files used for storing users/passwords for HTTP Digest Authentication.

You just have a .htaccess file. I don't think you need the [L] flag as that signals the end of URL rewriting for that request. Why do you have a period preceding the home, settings, seed?

Other than that everything else looks good. And to answer your last question, no you don't have to close a .htaccess file. It's not like PHP where you need to supply the ending (?>) tag.


Personally I find this approach easier to handle - having to dive into htaccess every time you add to a site is quite dull.

I add a few file extensions to the list and don't do the existence of file checking in code but those are changes you can make according to your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号