Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Mod rewrite problem

Posted on 2008-10-06
4
193 Views
Last Modified: 2012-05-05
I have made a rewrite rule
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?id=$1/$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?id=$1/$2

if the url is www.domain.ee/products/product then for the php is url www.domain.ee/index.php?id=products/product
so far ok.
But if the url is www.domain.ee/products/product and i write HTML <img src="WWW_files/img.jpg/">
then the img paht is www.domain.ee/products/product /WWW_files/img.jpg

How can i do this,  no matter how deep is the url (www.domain.ee/1/2/3/4...../199) for the html always get www.domain.ee/WWW_files

I hope you understand my bad english.

but if i write html
0
Comment
Question by:GenTaliaru
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 22655347
You can redirect the folder WWW_files to the root level with the code below. Another approach: Modify your HTML source code to

src="/WWW_files/img.jpg/" (leading slash) or with

<base href="http://example.com/">  in your <head>....</head> section of a html page.
RewriteRule .(/WWW_files/.*)$ $1 [R=301,L]

Open in new window

0
 

Author Closing Comment

by:GenTaliaru
ID: 31503583
Thanks a lot
0
 

Author Comment

by:GenTaliaru
ID: 22656996
Can you explain me what         

RewriteRule .(/WWW_files/.*)$ $1 [R=301,L] means?
0
 
LVL 27

Expert Comment

by:caterham_www
ID: 22657645
.  one character followed by
/WWW_files/  literally followed by
.*  0 or n characters; capture the matched result within (...)  in a backreference
$ end of string

$1 is the notation of the backreference in the substitution

R=301 forces a redirect with HTTP status code 301
L stands for last rule.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XAMPP 14 48
PHP in Apache server 20 101
Redirect and Rewrite URL using .htaccess 38 131
How code a 301 redirect for folder files -> 1 file 2 58
As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question