Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
ReWriteRule for /filename/query_string !
Old 08-20-2008, 12:10 PM ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
Hello,

I'm totally newbie with ReWriteRules, so I just made a simple one , which is :

RewriteRule ^(.*)/(.*) $1.php?$2

it works fine, so it's rename the 1st match 2 file name, then 2nd match to query string, so as I can get all variables in this file name.

But I've the problem, that now I can't load images, css, js, etc. cause it's looking for images.php istead of /images/

so, how can I exclude, images, style, js folders ?
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
 
Register now for full access!
Old 08-20-2008, 01:56 PM Re: ReWriteRule for /filename/query_string !
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
Use a rewritecondition:

in this example the file index.php and the entire directorys scripts, styles and images are ignored.
Code:
RewriteCond %{REQUEST_URI} !^/index.php|/scripts|/styles|/images
RewriteRule ^(.*)/(.*) $1.php?$2

Last edited by bas; 08-20-2008 at 01:58 PM..
bas is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 02:07 PM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
it still doesn't work man !!

If I typed :
http://localhost/clienetname.com/file_name/

it loads :
http://localhost/clientname.com/file_name.php

and that's fine, but it looks for images on :/file_name/images/image_name !!!
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-20-2008, 02:12 PM Re: ReWriteRule for /filename/query_string !
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
it doesn't work because you're not in the root directory, try:
Code:
RewriteCond %{REQUEST_URI} !^/clienetname.com/file_name
bas is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 02:34 PM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
Thanks a lot bas for ur efforts, but still doesn't work !!

I changed apache document root, and here's url :
http://localhost/categories/

and here's access.log error :
"GET /categories/images/home_bottom_shadow.jpg HTTP/1.1" 404 1262

and here's error.log error :
File does not exist: D:/xampp/htdocs/clients/clientname/categories, referer: http://localhost/categories/

finally, here's .htaccess content :
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.php|/images|/style|/js
RewriteRule ^(.*)/(.*) $1.php?$2
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-20-2008, 03:14 PM Re: ReWriteRule for /filename/query_string !
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
if url is: http://localhost/categories/

the dir that need to be ignored is http://localhost/categories/images/

and .htacces is in directory categories

then .htaccess content should be:
Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/categories/images
RewriteRule ^(.*)/(.*) $1.php?$2
bas is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 03:24 PM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
I think u misunderstood me !!
categories should load categories.php , so
http://localhost/categories/ loads http://localhost/categories.php

and the images folder location is http://localhost/images
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-20-2008, 03:39 PM Re: ReWriteRule for /filename/query_string !
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
idd i did, again then:

if main url is http://localhost/
and images folder is http://localhost/images
.htaccess is in root directory

this should really work:
Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/images
RewriteRule ^(.*)/(.*) $1.php?$2
now
http://localhost/categories/ is rewritten to http://localhost/categories.php
http://localhost/images/ loads http://localhost/images/
and http://localhost/images/file.png loads http://localhost/images/file.png

Last edited by bas; 08-20-2008 at 03:41 PM..
bas is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 03:40 PM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
btw, I can access the files directly fine , when using :
RewriteCond %{REQUEST_URI} !^/index.php|/images|/style|/js

btw, I'm using relative paths in all images & css, should I use absolute paths ??
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-20-2008, 03:43 PM Re: ReWriteRule for /filename/query_string !
bas
Super Talker

Posts: 108
Name: Bas
Trades: 0
Quote:
Originally Posted by alex_funky_dj View Post
btw, I can access the files directly fine , when using :
RewriteCond %{REQUEST_URI} !^/index.php|/images|/style|/js

btw, I'm using relative paths in all images & css, should I use absolute paths ??
yes you should.
maybe using the base-element would work to ... but don't know for sure
bas is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 03:44 PM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
yes, all thes problems were becaise the paths was relative, when I make ti absolute, now works fine
thanks a lot man, really thanks a lot
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-20-2008, 04:08 PM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
btw, here's another way, I just discovered, to override the absolute paths issue
RewriteRule ^(.*)/images/(.*)$ /images/$2 [L]
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-21-2008, 04:04 AM Re: ReWriteRule for /filename/query_string !
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
OMFG, GO READ THE FKIN MANUAL!

RewriteRule images|styles|files|whatever|etc - [L]

Why don't you read the fkin manual BEFORE posting into forum? Both of you, the topicstarter and the advisor!
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-21-2008, 05:23 AM Re: ReWriteRule for /filename/query_string !
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Quote:
Originally Posted by mtishetsky View Post
OMFG, GO READ THE FKIN MANUAL!

RewriteRule images|styles|files|whatever|etc - [L]

Why don't you read the fkin manual BEFORE posting into forum? Both of you, the topicstarter and the advisor!
Mtishetsky matey.

I've observed a lot of your posts over the months and I can say without fear of contradiction that you come across as one unpleasant MF.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 08-21-2008, 05:28 AM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
Quote:
Originally Posted by mtishetsky View Post
OMFG, GO READ THE FKIN MANUAL!

RewriteRule images|styles|files|whatever|etc - [L]

Why don't you read the fkin manual BEFORE posting into forum? Both of you, the topicstarter and the advisor!
cause it's fkin complicated and not that easy !! in comparison with PHP / MySQL manuals !
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Old 08-21-2008, 05:36 AM Re: ReWriteRule for /filename/query_string !
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Manuals are written to be read, not to only waste your disk space. If you are too dumb to understand the manual - quit web development and go wash cars.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-21-2008, 05:47 AM Re: ReWriteRule for /filename/query_string !
Experienced Talker

Posts: 32
Name: Mahmoud M. Abdel-Fattah
Location: Alexandria, Egypt.
Trades: 0
Sorry man, there's no available vacancies in car washing in our city !!
m_abdelfattah is offline
Reply With Quote
View Public Profile Visit m_abdelfattah's homepage!
 
Reply     « Reply to ReWriteRule for /filename/query_string !
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50727 seconds with 12 queries