views:

41

answers:

1

i have some question about the syntax of module rewrite. i would like to know how to write a rule to not include/contain some file?

For example:

Directories structure:

  • /
  • /home.php
  • /profile.php
  • /pages
  • /pages/index.php
  • /pages/.htaccess

About the /pages/index.php content:

<?php include_once "../home.php" ?>

About the /home.php content:

<a href="profile.php">Profile</a>

So: i would like to write a .htaccess in the pages directory, and make the hyperlink (profile.php) is correct when user click on Profile text.

RewriteEngine On
RewriteBase /pages2

RewriteRule ^(images|css|js|plugins)/(.*) http://localhost/$1/$2

# if end with .php ext and file name not index.php then redirect to parent directory
RewriteCond %{SCRIPT_FILENAME} .php$
RewriteCond %{SCRIPT_FILENAME} !index.php$ ## not work ?
RewriteRule ^(.*) http://localhost/$1

In this case , i can not change the root path file content.

A: 

lol you don't need any rules :) just make it

<a href="/profile.php">Profile</a>
Col. Shrapnel
But i can not change the root file content .
Zeuxis
@Zeuxis you don't need to change the root of anything. Just write it this way. That's just an address of your profile.php file. You did write it yourself this way in your question: `/profile.php`. And that's right addres. JUST USE IT
Col. Shrapnel
seems like the "/pages" directory is the webroot of his website, therefore, /profile.php is not accessible this way.To be honest, the whole thing seems like a contrived design, to me.
SirDarius
@SirDarius but we have a home.php which is in the / root. Yeah, the more I see on it the more contrived it seems. Especially these localhost redirects.
Col. Shrapnel
@Col.Shrapnel i means the content was included the hyperlink, because the root file is not maintain by mine. so, i choice the mod_rewirte method to help me to complete the works.
Zeuxis