2012-01-20 16 views
9

मुझे कुछ यूआरएल पुनर्लेखन में परेशानी हो रही है।.htaccess यूआरएल पुनर्लेखन चुनौती

नीचे दी गई सभी चीज़ें ठीक काम करती हैं, लेकिन मुझे एक नियम जोड़ने की आवश्यकता है जो URLS से क्वेरीस्ट्रिंग को हटा देता है।

site.com/page?a=b बन जाएगा site.com/page

किसी को बाहर करने में मदद कर सकते हैं? मैंने htaccess पर कुछ पढ़ा है लेकिन मुझे यह बहुत जटिल लगता है। साथ ही, यह जानने की आवश्यकता होगी कि फ़ाइल में मेरे नए निर्देश कहां दिखाना चाहिए।

धन्यवाद।

 

    # EE 404 page for missing pages 
    ErrorDocument 404 /index.php/404/index 

    # Simple 404 for missing files 
    
     ErrorDocument 404 "File Not Found" 
    

    # Rewriting will likely already be on, uncomment if it isnt 
    
    RewriteEngine On 
    RewriteBase/
    

    # Block access to "hidden" directories whose names begin with a period. This 
    # includes directories used by version control systems such as Subversion or Git. 
    
     RewriteRule "(^|/)\." - [F] 
    

    # remove the www - Uncomment to activate 
    # 
    # RewriteCond %{HTTPS} !=on 
    # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
    # RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 
    # 

    # Remove the trailing slash to paths without an extension 
    # Uncomment to activate 
    # 
    # RewriteRule ^(.*)/$ /$1 [R=301,L] 
    # 

    # Remove index.php 
    # Uses the "include method" 
    # http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method 
    # 
    RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC] 
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$ 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} ^/(home|inc|publishers|sidebars|about|include-template|testing|advertisers|products|sitemap|style|ad-choices|social-bar|search|404||members|P[0-9]{2,8}) [NC] 
    RewriteRule (.*) /index.php/$1 [L] 

+0

बस अपने अंतिम नियम में '$ 1' के बाद'? 'जोड़ें। 'पुनर्लेखन (। *) /index.php/$1? [एल] ' – Virendra

उत्तर

9

इस यूआरएल

RewriteRule ^(.*) /index.php/$1? [L] #remove query string 

से क्वेरी स्ट्रिंग हटा आशा है कि यह

2

में मदद करता है मैं एक जवाब के लिए देर से एक छोटे से कर रहा हूँ, लेकिन जब से मैं एक ऐसे ही व्यवहार के लिए खोज रहा था, मैंने सोचा मुझे इसे साझा करना चाहिए: आप क्वेरी स्ट्रिंग को हटाने के लिए एक पुनःलेख नियम में ध्वज भी जोड़ सकते हैं; ध्वज [QSD] है, और यह अंत में ? जैसे वर्कअराउंड से बचने में मदद करता है ;-)

Here आप इस ध्वज के बारे में अधिक जानकारी प्राप्त कर सकते हैं। मुझे यह इंगित करना पसंद है कि "यह ध्वज [अपाचे] संस्करण 2.4.0 में और बाद में"

संबंधित मुद्दे