2

I have url like this:

www.site.com/index.php?/genero/aventura/av/

But I would like this to be my new url:

site.com/genero/aventura/av/

I used the following code:

<IfModule mod_rewrite.c>RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.site.com/$ [NC]
RewriteRule ^index.php\?/(.*)$ site.com/$1 [R=301,L]
</IfModule>

but only returns me: site.com/index.php?/genero/aventura/av/

This is my latest & full version:

RewriteEngine on
#RewriteCond $1 !^(index\.php|ver_capitulo\.html|google3436eb8eea8b8d6e\.html|BingSiteAuth\.xml |portadas|public|mp3|css|favicon\.ico|js|plantilla|i|swf|plugins|player\.swf|robots\.txt)
RewriteCond $1 !^(index\.php|public|css|js|i|feed|portadas|robots\.txt|BingSiteAuth\.xml|plugins|i|mp3|favicon\.ico|pluginslist\.xml|google3436eb8eea8b8d6e\.html)
RewriteRule ^(.*)$ /index.php?/$1 [L]

#DirectoryIndex index.php
#RewriteCond %{THE_REQUEST} http://www.page.com/index\.php [NC]
#RewriteRule ^(.*?)index\.php$ http://page.com/$1 [L,R=301,NC,NE]

#DirectoryIndex index.php
#RewriteEngine On

Thanks for reading.

  • The `Host:` name does not contain a trailing slash. And the query string is not available as RewriteRule path, but only [in `%{QUERY_STRING}`](https://wiki.apache.org/httpd/RewriteQueryString). Your rules, btw, only redirect to the intended new URL scheme. Unless you also process the then incoming normalized paths, the index.php handler script won't be invoked. – mario Jun 06 '14 at 14:42

1 Answers1

0

Replace your rule with this:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|public|css|js|i|feed|portadas|robots\.txt|BingSiteAuth\.xml|plugins|i|mp3|favicon\.ico|pluginslist\.xml|google3436eb8eea8b8d6e\.html)
RewriteRule ^(.*)$ /index.php?/$1 [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I try in this way so that it contains the www: DirectoryIndex index.php RewriteEngine On RewriteCond %{THE_REQUEST} www.page.com/index\.php [NC] RewriteRule ^(.*?)index\.php$ page.com/$1 [L,R=301,NC,NE] but still has not been solved – Francis Goris Jun 06 '14 at 15:07
  • Why did you make in `RewriteCond %{THE_REQUEST} www.page.com/index\.php` instead of what I suggested? – anubhava Jun 06 '14 at 15:11
  • You also use your suggestion, and gave me the same result, try removing www. and also index.php? because when I try to remove the www. I just goes to index.php?, I remove both (www and index.php?). – Francis Goris Jun 06 '14 at 15:16
  • Paste your latest & full .htaccess in your question. – anubhava Jun 06 '14 at 15:17
  • Now you can see the code above, I posted the part – Francis Goris Jun 06 '14 at 15:23
  • see updated code, copy/paste it as it (don't change). – anubhava Jun 06 '14 at 15:28
  • The result is www.page.com/?/section/1, but I need to remove the "www" and "?" in this update so that it is http:// page.com/section/1 – Francis Goris Jun 06 '14 at 15:43
  • Your question title says: **How to remove “index.php?” from HTACCESS** Don't add more questions via comments. Accept this answer and create a new question for other problems. – anubhava Jun 06 '14 at 15:45
  • Oh, right, thank you very much for your help anubhava – Francis Goris Jun 06 '14 at 15:46
  • You should mark the answer accepted by clicking on tick mark on top-left of my answer. – anubhava Jun 06 '14 at 16:25
  • Sorry I was offline, your answer is useful for the question asked. Already marked you for being very helpful. – Francis Goris Jun 06 '14 at 18:44