Forum

Thread tagged as: Problem, Docs

I get an empty Array ( ) as a result.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So the query string parameter is definitely getting lost as part of the rewrite. This is before it gets to Perch.

Any idea how to pass that parameter and still have a rewrite?

Stack Overflow suggests QSA flag but that is not working.

Drew McLellan

Drew McLellan 2638 points
Perch Support

QSA would take the query string from the left and apply it to the right. That's not what you want here.

What does your rewrite rule currently look like?

RewriteRule ^/site-2/detail/([a-zA-Z0-9-/]+)$ /site-2/detail.php?s=$1 [QSA,L,R]

I also tried this thinking that the REGEX wasn't open enough:

RewriteRule ^/site-2/detail/(.*) /site-2/detail.php?s=$1 [QSA,L,R]

Neither work

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you give an example of the URL you're testing?

Been trying these three:

/detail/test-item-1 /detail/test-item-2 /detail/science

Drew McLellan

Drew McLellan 2638 points
Perch Support

Try:

RewriteRule ^detail/([a-zA-Z0-9-/]+)$ /detail.php?s=$1 [L]

Does nothing.

That's the same as in the tutorial. Also tried this and got nothing:

RewriteRule ^site-2/detail/([a-zA-Z0-9-/]+)$ /site-2/detail.php?s=$1 [L]
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's a limit to what I can do from here. Do you have other rules that could be acting on the same path?

There shouldn't be - I've dumped everything else from my .htaccess file and I can't think that there would be something anywhere else that would effect this.

I'm preparing to post this over on stackoverflow and see if anyone can tell me where else to look to solve this problem. If I cannot get it to work I will just revisit the architecture plan for this site and do without the rewrites.

Thank you for all your help Drew, you've been amazingly patient with this.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Rewrites are such a pain. Did you know Runway handles it all for you? There's another option! :-)

I'll consider it but since this project is ultimately just going to be my personal portfolio site that seems like a big upgrade.

One more question though Drew...

I've noticed that if I remove ALL the rules from .htaccess I can still pull up detail.php by pointing my browser at /detail/test-item-1... so its behaving as if there is still some sort of rewrite in place - is this default Perch behavior or a clue that there is probably something off somewhere else in my server config?

StackOverflow to the rescue!

Important is to turn off MultiViews options here. Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.

My .htaccess now works and looks like:

<IfModule mod_rewrite.c> 
Options -MultiViews
RewriteEngine on

RewriteRule ^detail/([a-zA-Z0-9-/]*)$ detail.php?s=$1 [L,QSA,NC]

</IfModule>

Thank you again for all your help Drew!