34831

mod_rewrite http://localhost/home/ or http://localhost/home to home.php

Question:

I've got a really simple question. I want to redirect all requests to <a href="http://localhost/home/" rel="nofollow">http://localhost/home/</a> and <a href="http://localhost/home" rel="nofollow">http://localhost/home</a> to home.php

My .htaccess file contains:

RewriteRule ^home/$ home.php [L]

which only works for <a href="http://localhost/home/" rel="nofollow">http://localhost/home/</a>

How can I make it work without the /in the url too? Is it possible to do it in one line, as opposed to two separate lines such as:

RewriteRule ^home/$ home.php RewriteRule ^home$ home.php

Thanks :)

Answer1:

RewriteRule ^home/?$ home.php [L]

Answer2:

RewriteRule ^home/?$ home.php

Recommend

  • How to generate url redirects similar to stackoverflow using .htaccess and php?
  • Change current working directory from batch file and run script
  • PHPUnit cannot find exception class
  • Class 'PhpOffice\\PhpSpreadsheet\\Spreadsheet' not found
  • Help with mod_rewrite
  • Removing the .php file extension from the URL Request
  • Generating random numbers directly inside a .htaccess file
  • Ionic storage “get” returns null only on the second call within method
  • CORS with socket.io
  • File extension of zlib zipped html page?
  • mave 3.2 not able to access local nexus instance return 502 code
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • Can my PDF ping my server when it is opened?
  • pip in virtualenv gets ConnectTimeoutError
  • Tomcat memory Leak
  • Element.tagName for python not working
  • Unable to install Git-core+svn by MacPorts
  • Django simple Captcha “No module named fields” error
  • htaccess add www if not subdomain, if subdomain remove www
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • Could not find rake using whenever rails
  • Android full screen on only one activity?
  • Cannot resolve symbol 'MyApi'
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • Accessing IRQ description array within a module and displaying action names
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • How to make Safari send if-modified-since header?
  • Web-crawler for facebook in python
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Arrays break string types in Julia
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • need help with bizarre java.net.HttpURLConnection behavior
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy