Answers.Body: <p>Taken from this answer on Stack Overflow: 
  <a href="https://stackoverflow.com/a/1219119/1013978">.htaccess mod_rewrite: rewriting querystring to path</a></p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      # Remove index.php
      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
      RewriteCond %{REQUEST_URI} !^/index\.php/admin\b [NC] # Don't mess with admin requests
      RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
  
      # Remove ?p=
      RewriteCond %{THE_REQUEST} ^GET\ /\?(([^&amp;\s]*&amp;)*)p=([^&amp;\s]+)&amp;?([^\s]*)
      RewriteRule ^(.*)$ /%3?%1%4 [L,R=301]
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>This not only reformats <code>/?p=about</code> as <code>/about</code>, but it also preserves other parts of the query string.</p>
  
  <p>For example, <code>/?p=about&amp;tag=stuff</code> and even <code>/?tag=stuff&amp;p=about</code> both redirect to <code>/about?tag=stuff</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-31T08:57:57.627Z
Answers.Text: If i use this then i cannot login to admin dashboard anymore.... Any idea?
Answers.UserDisplayName: Paulv12345
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T17:24:02.003Z
Answers.Text: If you are using a different url other than `/admin` to access your control panel, you will need to update line 6 above and replace "admin" with your custom control panel trigger.
  
  `RewriteCond %{REQUEST_URI} !^/index\.php/your-custom-cp-trigger\b [NC]`
Answers.UserDisplayName: Alex Roper
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-02T05:53:58.257Z
Answers.LastActivityDate: 2017-03-02T05:53:58.257Z
Answers.LastEditDate: 2017-05-23T12:38:53.957Z
Answers.UserDisplayName: Alex Roper
Body: <p>I discovered search engines found duplicate content on my domain due to URLs being output with <code>index.php?p=</code> and <code>index.php</code> in ADDITION to the clean URLs.</p>
  
  <p>For example, I have:</p>
  
  <ol>
  <li><code>domain.com/index.php?p=about</code></li>
  <li><code>domain.com/index.php/about</code></li>
  <li><code>domain.com/about</code></li>
  </ol>
  
  <p>And the first two requests with <code>index.php?p=</code> and <code>index.php</code> shouldn't exist. Only the last request with <code>domain.com/about</code> should exist.</p>
  
  <p>While I found help removing <code>index.php</code>, some URLs continue to include <code>?p=</code>.</p>
  
  <p>So, now I still have:</p>
  
  <ol>
  <li><code>domain.com/?p=about</code></li>
  <li><code>domain.com/about</code></li>
  </ol>
  
  <p>While all I want is:</p>
  
  <ol>
  <li><code>domain.com/about</code></li>
  </ol>
  
  <p>Note: This is happening to several pages and blog entries throughout the site. Not only URLs directed to <code>about</code>.</p>
  
  <p>How may I remove <code>?p=</code> permanently from the remaining URLs?</p>
  
  <p>Within .htaccess, I have:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      # Remove index.php
      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
      RewriteCond %{REQUEST_URI} !^/index\.php/admin\b [NC] # Don't mess with admin requests
      RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Within craft/config/general.php, I have:</p>
  
  <pre><code>return array(
      '*' =&gt; array(
  
          'omitScriptNameInUrls' =&gt; true,
      ),
  );
  </code></pre>
  
Tags: <url><config><htaccess>
Title: How to remove index.php?p= permanently?
ThreadText: # How to remove index.php?p= permanently?
  
  (Asked by: username_0 on 2017-03-02)
  
  I discovered search engines found duplicate content on my domain due to URLs being output with `index.php?p=` and `index.php` in ADDITION to the clean URLs.
  
  For example, I have:
  
  1. `domain.com/index.php?p=about`
  2. `domain.com/index.php/about`
  3. `domain.com/about`
  
  And the first two requests with `index.php?p=` and `index.php` shouldn't exist. Only the last request with `domain.com/about` should exist.
  
  While I found help removing `index.php`, some URLs continue to include `?p=`.
  
  So, now I still have:
  
  1. `domain.com/?p=about`
  2. `domain.com/about`
  
  While all I want is:
  
  1. `domain.com/about`
  
  Note: This is happening to several pages and blog entries throughout the site. Not only URLs directed to `about`.
  
  How may I remove `?p=` permanently from the remaining URLs?
  
  Within .htaccess, I have:
  
  ```
  <IfModule mod_rewrite.c>
      RewriteEngine On
  
      # Remove index.php
      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
      RewriteCond %{REQUEST_URI} !^/index\.php/admin\b [NC] # Don't mess with admin requests
      RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  </IfModule>
  
  ```
  
  Within craft/config/general.php, I have:
  
  ```
  return array(
      '*' => array(
  
          'omitScriptNameInUrls' => true,
      ),
  );
  
  ```
  
  **Tags:** url, config, htaccess
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-02. Score: 7 | Accepted answer
  
  Taken from this answer on Stack Overflow:
  [.htaccess mod\_rewrite: rewriting querystring to path](https://stackoverflow.com/a/1219119/1013978)
  
  ```
  <IfModule mod_rewrite.c>
      RewriteEngine On
  
      # Remove index.php
      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
      RewriteCond %{REQUEST_URI} !^/index\.php/admin\b [NC] # Don't mess with admin requests
      RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
  
      # Remove ?p=
      RewriteCond %{THE_REQUEST} ^GET\ /\?(([^&\s]*&)*)p=([^&\s]+)&?([^\s]*)
      RewriteRule ^(.*)$ /%3?%1%4 [L,R=301]
  
      # Send would-be 404 requests to Craft
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteRule (.+) index.php?p=$1 [QSA,L]
  </IfModule>
  
  ```
  
  This not only reformats `/?p=about` as `/about`, but it also preserves other parts of the query string.
  
  For example, `/?p=about&tag=stuff` and even `/?tag=stuff&p=about` both redirect to `/about?tag=stuff`.
  
  > **Comments:**
  > **username_2**: If i use this then i cannot login to admin dashboard anymore.... Any idea?  
  > **username_1**: If you are using a different url other than `/admin` to access your control panel, you will need to update line 6 above and replace "admin" with your custom control panel trigger.  `RewriteCond %{REQUEST_URI} !^/index\.php/your-custom-cp-trigger\b [NC]`  
  
  ---
  
  