简体   繁体   中英

.htaccess file to implement httpd.conf changes

I need to make the following changes to my server's httpd.conf

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

AllowOverride All
AccessFileName .htaccess

However, i was told that making direct change is not possible as it is a shell server so there is a need to use mod_rewrite via a .htaccess file.

My question is now, how do I convert the codes? I've tried searching everywhere but could not find any answer to this. Sorry that I am a newbie in this area.

Thank you very much.

Regards, Sean

I understand that your server is set to not allow you access to httpd.conf but rather gives you the ability to create .htaccess files to do your needed mod_rewrites. This is a typical scenario. You do not need to write anything to httpd.conf to make that happen. It is already done for you.

To create mod_rewrites you need to create an .htaccess file with any text editor with that name and no extension but with a preceding period (.) and save it to your domain root directly eg. www.yourdomain.com/.htaccess

Inside this file you would then write your mod_rewrite code following this pattern:

RewriteCond test_string cond_pattern

The following mod_rewrite code is oftentimes used with WordPress to allow pages and posts to have a more sensible permalink pattern:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

A good article to read on this topic can be found at: fubra.com

You cannot. Your settings basically instruct Apache to use .htaccess as per-directory configuration file and grant such files all available permissions. Obviously:

  1. You can't put instructions to find a file in that file (it's like keeping the safe's keys inside the locked safe).
  2. The file is not allowed to grant himself those permissions.

The interesting point is why exactly you need those changes, given that .htaccess is already the default value and the other directives are something the hosting services grant or deny according to their policies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM