473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RewriteRule

I have:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&ti tle=$2 [NC]

rewrites domain.com/index?language= en&title=home to domain.com/en/home

Problem: to link to css-files, images etc I have to use '../' to go
into an upper folder, while this shouldn't be necessary. It is because
of de 'folder' 'en' which is in the address field of the browser.

Is there a possibility to resolve this?

Using '/' does not help, because the web app is not in the root.

Thanks in advance
Nov 9 '08 #1
7 3090
On Nov 9, 9:05*am, betty <123be...@gmail .comwrote:
I have:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&ti tle=$2 [NC]

rewrites domain.com/index?language= en&title=home to domain.com/en/home

Problem: to link to css-files, images etc I have to use '../' to go
into an upper folder, while this shouldn't be necessary. It is because
of de 'folder' 'en' which is in the address field of the browser.

Is there a possibility to resolve this?

Using '/' does not help, because the web app is not in the root.

Thanks in advance
Add this before the RewriteRule. It will effectively exclude files and
directories from the rewrite:
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d

By the way, it may be easier for you to just use this RewriteRule:
RewriteRule ^(.*)$ index.php?query =$1 [L,QSA]

And parse $_GET['query'] using PHP. That's definitely more flexible.

Thomas

Nov 9 '08 #2
On Nov 9, 3:58*pm, 703designs <thomasmal...@g mail.comwrote:
Add this before the RewriteRule. It will effectively exclude files and
directories from the rewrite:
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d

By the way, it may be easier for you to just use this RewriteRule:
RewriteRule ^(.*)$ index.php?query =$1 [L,QSA]

And parse $_GET['query'] using PHP. That's definitely more flexible.

Thomas
Thank you for your answer.

If I use RewriteCond, I still am having problems with linking files
like css.

Could you tell me how I would be able to 'parse $_GET['query'] using
PHP'? By looking for '/' and extract the values, or is there a better
way to do that?
Is it true that I still would need the RewriteCond?
Nov 9 '08 #3
On Nov 9, 3:58*pm, 703designs <thomasmal...@g mail.comwrote:
On Nov 9, 9:05*am, betty <123be...@gmail .comwrote:
I have:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&ti tle=$2 [NC]
rewrites domain.com/index?language= en&title=home to domain.com/en/home
Problem: to link to css-files, images etc I have to use '../' to go
into an upper folder, while this shouldn't be necessary. It is because
of de 'folder' 'en' which is in the address field of the browser.
Is there a possibility to resolve this?
Using '/' does not help, because the web app is not in the root.
Thanks in advance

Add this before the RewriteRule. It will effectively exclude files and
directories from the rewrite:
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d

By the way, it may be easier for you to just use this RewriteRule:
RewriteRule ^(.*)$ index.php?query =$1 [L,QSA]

And parse $_GET['query'] using PHP. That's definitely more flexible.

Thomas
On Nov 9, 3:58 pm, 703designs <thomasmal...@g mail.comwrote:
Add this before the RewriteRule. It will effectively exclude files and
directories from the rewrite:
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d
By the way, it may be easier for you to just use this RewriteRule:
RewriteRule ^(.*)$ index.php?query =$1 [L,QSA]
And parse $_GET['query'] using PHP. That's definitely more flexible.
Thomas
Thank you for your answer.

If I use RewriteCond, I still am having problems with linking files
like css.

With using ?language=$1&ti tle=$2 I can extract the value language by
doing $_GET['language'].
Could you tell me how I would be able to 'parse $_GET['query'] using
PHP'? By looking for '/' and extract the values, or is there a better
way to do that?

Is it true that I still would need the RewriteCond?
Nov 9 '08 #4
On Nov 9, 10:31*am, betty <123be...@gmail .comwrote:
On Nov 9, 3:58*pm, 703designs <thomasmal...@g mail.comwrote:
On Nov 9, 9:05*am, betty <123be...@gmail .comwrote:
I have:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&ti tle=$2 [NC]
rewrites domain.com/index?language= en&title=home to domain.com/en/home
Problem: to link to css-files, images etc I have to use '../' to go
into an upper folder, while this shouldn't be necessary. It is because
of de 'folder' 'en' which is in the address field of the browser.
Is there a possibility to resolve this?
Using '/' does not help, because the web app is not in the root.
Thanks in advance
Add this before the RewriteRule. It will effectively exclude files and
directories from the rewrite:
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d
By the way, it may be easier for you to just use this RewriteRule:
RewriteRule ^(.*)$ index.php?query =$1 [L,QSA]
And parse $_GET['query'] using PHP. That's definitely more flexible.
Thomas

On Nov 9, 3:58 pm, 703designs <thomasmal...@g mail.comwrote:
Add this before the RewriteRule. It will effectively exclude files and
directories from the rewrite:
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d
By the way, it may be easier for you to just use this RewriteRule:
RewriteRule ^(.*)$ index.php?query =$1 [L,QSA]
And parse $_GET['query'] using PHP. That's definitely more flexible.
Thomas

Thank you for your answer.

If I use RewriteCond, I still am having problems with linking files
like css.

With using ?language=$1&ti tle=$2 I can extract the value language by
doing $_GET['language'].
Could you tell me how I would be able to 'parse $_GET['query'] using
PHP'? By looking for '/' and extract the values, or is there a better
way to do that?

Is it true that I still would need the RewriteCond?
I think that the easiest way is to use split, as in:

$params = split("/", $_GET['query']);
http://us3.php.net/split

In this case, URLs would be written like this:
/language/title
and be mapped to
/index.php?query =language/title

Thomas
Nov 9 '08 #5
betty escribió:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&ti tle=$2 [NC]

rewrites domain.com/index?language= en&title=home to domain.com/en/home

Problem: to link to css-files, images etc I have to use '../' to go
into an upper folder, while this shouldn't be necessary. It is because
of de 'folder' 'en' which is in the address field of the browser.

Is there a possibility to resolve this?

Using '/' does not help, because the web app is not in the root.
The browser doesn't know/care about the server's disk layout. If you add
slashes to the URL you *are* adding directory levels. So you have
several alternatives:

1. Replace slashes with anything else:

http://example.com/en-home

2. Fix your relative URLs, adding "../" as you said; it *is* necessary.

3. Build absolute URLs. PHP is a programming language, it should not be
a big issue to replace / with the appropriate value for your system ;-)
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Nov 10 '08 #6
betty wrote:
>I have:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&ti tle=$2 [NC]
I have had this problem ...

Just use <basehtml tag and problem should go away :-) Or use full URI in your
css include path etc.

Nov 10 '08 #7
Thanks to all for helping out.

I use now:
<base href="http://
<? echo $_SERVER['SERVER_NAME'];
echo substr($_SERVER['SCRIPT_NAME'], 0,
strrpos($_SERVE R['SCRIPT_NAME'], '/'));
?>
/" />
<link rel="stylesheet " href="css/main.css" type="text/css" />
Using only <base /is not good: when moving the website to another
folder, I have to change <base />.
Using only PHP to find the root folder, isn't good too: I have to put
it everywhere in the file when linking to a file like css or image.

SO I'm using a combination of both.

Is using $_SERVER['SERVER_NAME'] and $_SERVER['SCRIPT_NAME'] the
safest?
Nov 11 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2583
by: Phil Powell | last post by:
http://www.sitepoint.com/article/910/2] How can it be possible to use Apache's mod_rewrite module in such a way as to dynamically feed it variable information into the "RewriteRule" option? I am having to get info from a db call and then feed it into RewriteRule since the rule will be, to a degree, dynamic. Is this what I would be doing; if so, can I use a PHP script to call this, set the vars and make this happen? What must I do? ...
13
2105
by: Stephen Kay | last post by:
Is there a way to redirect every single page on an existing web site through a php function? In other words, say I have a whole functional HTML web site, never written to use any php. Now I would like to have a php function handle displaying every page, for example, instead of: http://www.mysite.com/mypage.html you would call:
3
2292
by: aljosa.mohorovic | last post by:
..htaccess file: RewriteRule ^test$ test.php RewriteRule ^test\/(.*)$ test.php/$1 my guess is that result should be equal: http://koncar.info/test.php/anything http://koncar.info/test/anything but for http://koncar.info/test/anything i get "No input file specified.".
7
4562
by: Jon Maz | last post by:
Hi, I'm having problems with a RewriteRule that's applied to url's with the % character in them, hope someone can help. The % character is a result of url-encoding non-ASCII words, as in the example below: 1. the word "sécurité" comes out of my db 2. I construct the following link, using the php urlencode function: <a href="/search/s%C3%A9curit%C3%A9">sécurité</a>
2
3743
by: RuthC | last post by:
Hi, In my website there is a facility for user to create there own pages we are maintaing this url as www.mywebsite.com/mypage/user created page name ex : www.mywebsite.com/mypage/ruth user created page name can contain alphanumeric charecters including '_' (no white space) I am using this code to redirect the user created pages RewriteRule ^mypage/(.*)/ mypage.php?u=$1
1
2594
by: dheeraj4uuu | last post by:
Hii I have an Smf forum, and i installed SEO4SMF to my forum and i made some modifications to my htaccess file.but after doing so everything works fine but i noticed that after going to some board in that board i a lot of topics so that there are some pages like ... pages when i clicked on the page 2 it just redirects me to the first page.. what i have to do???? here is my htaccess file
2
1608
by: JackpipE | last post by:
I need to rename a generic image to the name of the product that's being viewed on the page: /theme/images/fullProfile.gif to - /theme/images/ productxxx.jpg The productxxx.jpg image doesn't physically exist so I just need to rename the generic one and still display the same image under different name.
0
1636
by: macaco | last post by:
I'm trying to achieve the following: anydirectory/index.php?query_str --> anydirectory/index2.php?query_str anydirectory/anysubdirectory/index3.php?query_str --> anydirectory/anysubdirectory/index4.php?query_str What I need is to do a 301 from a page inside a directory to another page inside a directory (it's the same page name for every directory in my website, so, I know which are both pages but not which is the directory as it could be...
0
2268
Claus Mygind
by: Claus Mygind | last post by:
I have a helpDesk app. that sits on a server only accessible to our web users within our building. But we also have offices in other buildings through out the State. I would like to give access to the help desk for our remote users, but the server only has an internal IP address 999.9.9 and of course all our external users come through the external IP address 00.00.000.000. Without moving the app to my webserver that gives access to both...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.