473,738 Members | 11,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php and mod_rewrite?

ok. i give up. need help :)

here's the rule:

RewriteRule ^test/(.+)/(.*)$ /index.php$2

if i request: http://localhost/test/keyword/?show=files it properly
redirects me.

NOW, if i change the rule to: RewriteRule ^test/(.+)/(.*)$
/index.php$2&key =$1
it stops working.

i figured out that if i remove ? from $show=files and change the rule
to redirect to /index.php?$2, then i can use &key=$1. but i want to
figure out how to redirect the ?show=files request AND at the end add
&key=$1

thanks in advance!

Feb 2 '06 #1
6 1756
hi hru? im balaji. i have one big problem. Full details of
mod_rewrite() value in php with sample example give(plz) me. now one
small idea but most of process i can undrstand plz help me. plz tell me
soon .
na************@ msn.com wrote:
ok. i give up. need help :)

here's the rule:

RewriteRule ^test/(.+)/(.*)$ /index.php$2

if i request: http://localhost/test/keyword/?show=files it properly
redirects me.

NOW, if i change the rule to: RewriteRule ^test/(.+)/(.*)$
/index.php$2&key =$1
it stops working.

i figured out that if i remove ? from $show=files and change the rule
to redirect to /index.php?$2, then i can use &key=$1. but i want to
figure out how to redirect the ?show=files request AND at the end add
&key=$1

thanks in advance!


Feb 2 '06 #2
na************@ msn.com wrote:
ok. i give up. need help :)

here's the rule:

RewriteRule ^test/(.+)/(.*)$ /index.php$2

if i request: http://localhost/test/keyword/?show=files it properly
redirects me.

NOW, if i change the rule to: RewriteRule ^test/(.+)/(.*)$
/index.php$2&key =$1
it stops working.

i figured out that if i remove ? from $show=files and change the rule
to redirect to /index.php?$2, then i can use &key=$1. but i want to
figure out how to redirect the ?show=files request AND at the end add
&key=$1


RewriteRule does not match against the query string in mod_rewrite. To
match against that you will need to use

RewriteCond %{QUERY_STRING} pattern

RewriteRule works against the REQUEST_URI..

Therefore, as per your examples above:

RewriteRule ^test/(.+)/(.*)$ /index.php$2&key =$1

Consider this URI:
/test/dir1/dir2/?var=val

The result would be:
/index.phpdir2/&dir1

If you want to keep the original query string with your request, add the
[QSA] flag at the end of the RewriteRule statement (Query String Append)..

Using this with the same URI above...
RewriteRule ^test/([^/]+)/([^/]+)$ index.php?$2&ke y=$1 [QSA]

/index.php?dir2& key=dir1&var=va l

HTH

--
Justin Koivisto, ZCE - ju****@koivi.co m
http://koivi.com
Feb 2 '06 #3
Justin,

Thank you for your elaborate answer. Perhaps im not doing something
right, but here is what I get:

[Thu Feb 02 11:08:15 2006] [error] [client 127.0.0.1] File does not
exist: D:/system_programs/xampp/htdocs/gallery

This is in response to my request:

http://localhost/gallery/galleryname...how_per_page=5

That sould be processed with this rule:

RewriteRule ^gallery/([^/]+)/([^/]+)$ /index.php?$2&ga llery_name=$1
[QSA]

:) why?

P.S. Tried on my Apache server on a linux box - same result.

Feb 2 '06 #4
na************@ msn.com wrote:
Justin,

Thank you for your elaborate answer. Perhaps im not doing something
right, but here is what I get:

[Thu Feb 02 11:08:15 2006] [error] [client 127.0.0.1] File does not
exist: D:/system_programs/xampp/htdocs/gallery

This is in response to my request:

http://localhost/gallery/galleryname...how_per_page=5

That sould be processed with this rule:

RewriteRule ^gallery/([^/]+)/([^/]+)$ /index.php?$2&ga llery_name=$1
[QSA]

:) why?


^gallery/([^/]+)/([^/]+)$
match REQUEST_URI that:
* starts with literal "gallery/"
* followed by one or more characters that are not "/"
* followed by a "/"
* ends with one or more characters that are not "/"

Your request:
gallery/galleryname/
* starts with literal "gallery/"
* followed by one or more characters that are not "/"
* followed by a "/"
* DOES NOT end with one or more characters that are not "/"

You can modify the rule to accept this, or create a second rule, I opt
for modification:

RewriteRule ^gallery/([^/]+)(/([^/]+))?$ /index.php?$3&ga llery_name=$1 [QSA]

HTH

--
Justin Koivisto, ZCE - ju****@koivi.co m
http://koivi.com
Feb 2 '06 #5
still doesn't work :(

after playing around, i found this to work:

RewriteRule ^gallery/([^/]+)/(.*)$ /index.php?galle ry_name=$1$2 [QSA]

However, if my query string is
"mAIJX1CKDGM6nD Kq/QUfPXMxIKOrTdZQ rPcxAdM/DeJKhH9cycqCJrj ZsKgOePSF"
(that is, it contains "/"), then it's not interpreted properly. and i
believe it's my regex syntax in mode_rewrite.

This is simply a headache :) I spent so many hours on this one rule.
ouch. any ideas?

Thanks!

Feb 2 '06 #6
RewriteRule ^gallery/([^/]+)/$

worked.

Feb 4 '06 #7

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

Similar topics

1
2278
by: Westcoast Sheri | last post by:
Hello. How do I do this: If a visitor types in any number after my url, I want mod_rewrite to convert it to my url/anotherpage.html?number=number_visitor_typed Example: http://www.mysite.com/12345678.html would result in:
4
2550
by: Support | last post by:
Hello, I am running RedHat & Apache. RedHat does not allow creating more that 32000 subdirectories in one folder due to #defined constant limitation in the core code. I need to display 47000 directories on web page: e.g. mydomain.com/andrew , mydomain.com/bill , etc. Each directory contains .html/htm files and image files (*.jpg, *gif, jpeg etc.)
1
1512
by: Shabam | last post by:
In Apache there's a pretty powerful module called mod_rewrite. Is there anything like that in dot net?
11
2073
by: joelbyrd | last post by:
I have a people-networking type site in which each user has their own profile page, with their user id encoded. So, for example, the web address of their page might look like "www.example.com/my_profile.php?user_id=fdjkhfh2489298hf298h3s0dhfxj". I want the users to be able to choose their own web address that would look like "www.example.com/Joel", and then when they type in that address, they are automatically redirected to their profile...
4
2484
by: Hermann.Richter | last post by:
I want to rewrite URLs like http://domain/dir/file.php?var1=val1&var2=val2#anchor to http://domain/dir/file?var1=val1&var2=val2#anchor In other words, I want to strip out the php extension I tried putting in the .htaccess file the following:
5
4843
by: laredotornado | last post by:
Hi, I have verified that mod_rewrite is enabled on my Apache 2.2 instance. However, now I'm having a problem just serving pages using .htaccess files. Following Rik's advice, my .htaccess file is as follows RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} !^accesscontrol.php
2
2004
by: Susanne West | last post by:
hi group. i'm tackling a bigger project that will use mod_rewrite to patch a series of urls into a master php-script. this script builds the page framework that contains a series of elements that remain on every page. only a center part (a <div>) is filled with different contents, depending on how the page is called (= mode of the page). the point is, there are quite a few (approx 20) different 'modes' for the center part to be filled...
3
2325
by: Dr. No | last post by:
I am new to using mod_rewrite and am trying to rewrite a URL to pass values to my script so that: http://www.myclient.com/everything/animals/mammals/cats is transformed into http://www.myclient.com/index.php?nav=everything&nav=animals&nav=mammals@nav=cats Specifically, I am looking for an n-ary solution to this problem. I know how to
1
2877
by: jaimebienlesfruits | last post by:
Hi, I'm currently using mod_rewrite to rewrite URLs with server variables. RewriteEngine on RewriteRule ^(+)$ /layout4/$1/ RewriteRule ^(+)/?$ index.php?dir=&page=$1 RewriteRule ^(+)/(+)$ /layout4/$1/$2/ RewriteRule ^(+)/(+)/?$ index.php?dir=$1&page=$2
7
1739
by: Dale | last post by:
again, i know this is OT...just move along to the next post if it bugs you. :) i had been trying to have this: project.66.204.32.110 from the client browser, map to a virtual host where the document root would be:
0
9476
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
9263
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
8210
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
6751
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
4570
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
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
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.