Home Forum
2024-03-28
Benvenuto, Ospite
Nome Utente Password: Ricordami

Want to drop .php and redirect to what is left...
(1 Online) (1) Ospite
  • Pagina:
  • 1

ARGOMENTO: Want to drop .php and redirect to what is left...

Want to drop .php and redirect to what is left... 13 Anni, 8 Mesi fa #1281

  • jnlabbott
  • Offline
  • Fresh Boarder
  • Messaggi: 2
I have a site where I need everything that ends in .php to redirect to the same url, with the .php dropped.

Example:

From:
www.sitename.com/legal.php

To:
www.sitename.com/legal


I can do them one by one, but looking for a way to do it with a regex rule. Any ideas?
L'Argomento è stato bloccato.

Re:Want to drop .php and redirect to what is left... 13 Anni, 8 Mesi fa #1282

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
Hi.
You can do it with Apache mod_rewrite. Just a question:

From:
www.sitename.com/legal.php

To:
www.sitename.com/legal

Do the URL www.sitename.com/legal exists? Or you just want to drop .php but the page is www.sitename.com/legal.php?

In the latter case, you should use internal rewrite (i.e. the user call www.sitename.com/legal, and you Apache add a .php at the end and the internally www.sitename.com/legal.php).

Let me know what you really need,
Luigi
L'Argomento è stato bloccato.

Re:Want to drop .php and redirect to what is left... 13 Anni, 8 Mesi fa #1283

  • jnlabbott
  • Offline
  • Fresh Boarder
  • Messaggi: 2
Thanks, the pages do not exists (or at least they won't when we go live). The site is being ported over to Joomla, and we want to make sure search results and links in the wild redirect to the Joomla pages... there are about 200 for the site. We've managed to replicate the relative paths so that if the old site had:

www.sitename.com/somefolder/somepage.php

The Joomla site has the new content at:

www.sitename.com/somefolder/somepage
L'Argomento è stato bloccato.

Re:Want to drop .php and redirect to what is left... 13 Anni, 8 Mesi fa #1284

  • admin
  • Offline
  • Administrator
  • Messaggi: 1603
Ok,
in this case a simple regular expression using mod_rewrite should be the best solution. Something like this in .htaccess should work (add just after RewriteEngine On):

RewriteRule (.*).php$ /$1 [L]

Regards,
Luigi
L'Argomento è stato bloccato.
  • Pagina:
  • 1
Moderatori: admin
Tempo generazione pagina: 0.40 secondi
Cerca con Google
News
Chi è online
 92 visitatori online
Sponsor

slotmachineaamsonline.com è una guida alle migliori slot machine online legali in Italia. Sul sito trovi un elenco sempre aggiornato dei casino online con Slot machine e bonus slot, le ultime novità dal mondo delle slot online e le migliori strategie per vincere. Inoltre, è disponibile una sezione dedicata alle slot machine da BAR che finalmente sono disponibili nella versione online.