Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP how to get current rewrited URL excluding querystring?
    primarykey
    data
    text
    <p>I am using the following URL rewriting in .htaccess. </p> <pre><code>Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteRule ^([0-9]+)/([a-zA-Z0-9\&amp;_,-]+)$ business/business_home.php?business_id=$1 [L,QSA] RewriteRule ^([0-9]+)/([a-zA-Z0-9\&amp;_,-]+)/(about)$ business/business_about.php?business_id=$1 [L,QSA] RewriteRule ^([0-9]+)/([a-zA-Z0-9\&amp;_,-]+)/(products)$ business/business_products.php?business_id=$1 [L,QSA] RewriteRule ^([0-9]+)/([a-zA-Z0-9\&amp;_,-]+)/(enquiry)$ business/business_enquiry.php?business_id=$1 [L,QSA] RewriteRule ^([0-9]+)/([a-zA-Z0-9\&amp;_,-]+)/(contact)$ business/business_contact.php?business_id=$1 [L,QSA] ## hide .php extension # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s\?] [NC] RewriteRule ^ - [R=404,L] # To internally forward /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.+?)/?$ /$1.php [L] </code></pre> <p>Then How to get current rewrited URL excluding querystring? For eg: From the page having URL: <code>/22/somestring/enquiry?value=5&amp;page=9&amp;item=coffee</code> I expect: <code>/22/somestring/enquiry</code></p> <p>I tried with <code>$_SERVER['REQUEST_URI']</code> but it return <code>/22/somestring/enquiry?value=5&amp;page=9&amp;item=coffee</code> And also <code>$_SERVER['REDIRECT_URL']</code> give me what I expected, but it generates an <code>Notice: Undefined index: REDIRECT_URL</code> in some pages. And also <a href="https://stackoverflow.com/a/5493174/2050886">it doesn't work</a> in some servers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload