简体   繁体   中英

Url Rewrite problem: Cannot access my session and images from my re-written url

I used this rule on my site:

<IfModule mod_rewrite.c>
   Options +FollowSymlinks
    Options -Multiviews
    RewriteEngine on
    RewriteBase /

    RewriteCond %{HTTP_HOST} ^www.erecruitmentportal.com$
    RewriteRule ^(.*) http://erecruitmentportal.com/$1 [QSA,R=301]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ employers/page.php?page=$1 [L]
</IfModule>

When when one logs into the website, it sets a session only in the /employers/ directory. This means that only files in that directory can access the session.

Now after rewriting urls from http://example.com/name to http://example.com/employers/page.php?page= $1,

  1. i cannot access my sessions again
  2. in the employers folder, i have a folder - logos, now i cant access logos/pic.jpg from page.php (thats the url-rewritten version). It still sees the page from the root.

I am thinking its a rewrite base issue, so how do i modify this so it will work well for this, and not affect other rules that may follow.

Thanks

EDIT

This is my session settings:

session_start();
session_set_cookie_params ( $this->sessiontimeout, $this->subdomain, $this->website, 0, 1 );
//i want the session to be available only to files in a particular folder
ini_set('session.use_only_cookies', 1);

in your page header add base url like http://example.com/mysite in between your head tag. dont put www in ur base url.this is where ur page will start loading from

for the pictures you have to addres them as /employers/logos/pic.jpg

as for the sessions you're using it awfully wrong.
check permissions using some code logic, not clumsy HTTP requests.

Let your sessions to be available everywhere but check these sessions only in them files in a particular folder

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