vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Hiding .php with .htaccess file (https://vborg.vbsupport.ru/showthread.php?t=322503)

I.G.O.T.A. 05-02-2016 12:31 PM

Hiding .php with .htaccess file
 
Is it possible to hide the .php extension in the .htacess file? If so what is the best way to do you?

Thank you,
JJ

Paul M 05-02-2016 05:59 PM

What do you mean by "hide it" ?

Dave 05-02-2016 06:02 PM

<a href="http://stackoverflow.com/a/8371815/6275228" target="_blank">http://stackoverflow.com/a/8371815/6275228</a>

I don't see why you would want to do that though. If you currently have SEO .htaccess rules in place, it may mess up.

I.G.O.T.A. 05-03-2016 08:34 AM

Quote:

Originally Posted by Paul M (Post 2570020)
What do you mean by "hide it" ?

it would be just forum instead of forum.php

Quote:

Originally Posted by Dave (Post 2570021)
http://stackoverflow.com/a/8371815/6275228

I don't see why you would want to do that though. If you currently have SEO .htaccess rules in place, it may mess up.

I got that all taken care of, but I can't seem to get nothing to work to hide the extension. I can do it on Xenoforo, but not with vB.

In Omnibus 05-03-2016 09:12 AM

The extension is a function of the browser, not of the software.

I.G.O.T.A. 05-03-2016 08:49 PM

Quote:

Originally Posted by ProSportsForums (Post 2570057)
The extension is a function of the browser, not of the software.

So there is no way to do this?

Dave 05-03-2016 08:54 PM

It is possible, you just have to find the right .htaccess rules to rewrite any requests not containing .php in the URL to its version with .php in it. On top of that you should check if the file exits using another .htaccess rule.

cellarius 05-04-2016 04:52 AM

This is what I have been using in the past with non vB-sites:

Code:

## Internally rewrite extensionless file requests to .php files ##
#
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_fileNAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_fileNAME} !-f
# then add .php to get the actual filename
RewriteRule (.*) /$1.php [L]

## Externally redirect clients directly requesting .php page URIs to extensionless URIs
#
# If client request header contains php file extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.php\ HTTP
# externally redirect to extensionless URI
RewriteRule ^([^.]+).php$ http://your-domain.com/$1 [R=301,L]


## Force custom error page, since php does not return proper errors after this procedure ("no input file specified")
#
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^.+\.php$ /path/to/errorpage.php

Anyway - all of this will not remove the file extensions in vB, i.e. the links in the software will still be .php.

Having this used before: it works, but I would advise against using it. I wouldn't go through the potential trouble just for cosmetic reasons.

Paul M 05-04-2016 10:35 AM

The question is why do you want to do it ?

There is the option to use "Mod Rewrite Friendly URLs" in vB4, which (obviously) has to be combined with some htaccess rules (supplied) which will basically do what you want (use urls with no .php extension).

I.G.O.T.A. 05-04-2016 11:55 AM

Quote:

Originally Posted by Paul M (Post 2570113)
The question is why do you want to do it ?

There is the option to use "Mod Rewrite Friendly URLs" in vB4, which (obviously) has to be combined with some htaccess rules (supplied) which will basically do what you want (use urls with no .php extension).

We have that working, but the main forum still shows the .php. We've tried to hide with the code we have below and it works for what you see below, but not for the main forum.

# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]


All times are GMT. The time now is 10:27 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02215 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete