473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

passing variables from .htaccess

Dormilich
8,658 Expert Mod 8TB
Hi,

is there a possibility to pass variables from .htaccess to PHP?

I want to tell PHP, whether mod_rewrite is enabled (so I can use modified URLs in the navigation). what I've come up so far is adding another parameter to the URL, but I'm wondering, if there's a more elegant way (I know I can change settings of the php.ini)

Dormi
May 25 '09 #1

✓ answered by Atli

This should tell you whether mod_rewrite is available:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(function_exists('apache_get_modules') &&
  3.     in_array('mod_rewrite', apache_get_modules()))
  4. {
  5.    echo "mod_rewrite enabled!";
  6. }
  7. else {
  8.     echo "mod_rewrite disabled.";
  9. }
  10. ?>

4 4098
Ok, first of all .htaccess is server specific and you should avoid relying on it. PHP was meant to be server independent and does not provide any interfaces to access it.

With that said, the next best method I can think of is to put some meta comments in the .htaccess file and open it using fopen(). You can cache the required information somewhere so you won't have to open the file every time.
May 25 '09 #2
Markus
6,050 Expert 4TB
@Dormilich
It may be possible by doing something like:

Expand|Select|Wrap|Line Numbers
  1. php_flag variable_name variable_value
  2.  
Not sure though.
May 25 '09 #3
Atli
5,058 Expert 4TB
This should tell you whether mod_rewrite is available:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(function_exists('apache_get_modules') &&
  3.     in_array('mod_rewrite', apache_get_modules()))
  4. {
  5.    echo "mod_rewrite enabled!";
  6. }
  7. else {
  8.     echo "mod_rewrite disabled.";
  9. }
  10. ?>
May 26 '09 #4
Dormilich
8,658 Expert Mod 8TB
thanks Atli, this is what I was looking for.
May 26 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
14
by: Gregory | last post by:
Hello, I'm trying to do the above in order to process an image and return the result to an html image control. It fails and my key suspects are either the variable that I'm passing in -...
21
by: Thomas Mlynarczyk | last post by:
Hello, My provider has set register_globals = On and I can't change the php.ini file. Is there a way to unset all the imported get/post etc. variables at the beginning of my script? Thomas
4
by: Undercat | last post by:
Hi, I'm coding Php under register_global = off flag, but, most (all ?) of php hosting companies use the "on" flag with their shared servers... I spent too much time to finally discover that my...
28
by: Mike Wilcox | last post by:
I have the following code to select an item from a drop down menu and call the same script over again. I am expecting that after the first time the script is run the first echo would produce the...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
1
by: saravanatmm | last post by:
I have used htaccess file for static page. for example I have used the url for about us page But how can i do the htaccess for argument. could u please give me explanation for htaccess and...
8
by: sheldonlg | last post by:
I have a case where the session values appear to lose their value. I tracked it down with some print_r inserted. Here are the lines: print '<br 1: '; print_r($_SESSION); $adminLevel = $_POST;...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.