I have Apache/PHP setup on Windows 7. I am not able to visit /localhost/index.php or /localhost. I can open any other .php file from localhost or I can open index.php if it is in any subfolder of my documentroot.
Here are the relevant lines from httpd.conf
DocumentRoot "C:/public_html"
<Directory />
Options FollowSymLinks Indexes
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<Directory "C:/public_html">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Related
I finished my laravel project, I want to host it like this 192.168.1.50:8888 but it shows the same page as 192.168.1.50 which means it go to "E:/portal/www" instead of "E:/portal/www/system/public"
I did the following on apache configuration
My projects folder E:/portal/www contains a laravel project called system
I enabled vhosts in httpd.conf and did the following changes
DocumentRoot "E:/portal/www"
<Directory "E:/portal/www">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper E:/portal/php-7.1.6/php-cgi.exe .php
AllowOverride All
Require all granted
</Directory>
The httpd-vhosts.conf
Listen 80
Listen 8888
<VirtualHost 192.168.1.50:80>
ServerName localhost
DocumentRoot "E:/portal/www"
<Directory "E:/portal/www">
Options Indexes FollowSymLinks ExecCGI
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.50:8888>
ServerName system.dev
DocumentRoot "E:/portal/www/system/public"
<Directory "E:/portal/www/system/public">
Options Indexes FollowSymLinks ExecCGI
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
What should I do??
i have a problem with phpmyadmin installation via brew, i have modified my root directory to point to /Users/username/Sites in /usr/local/etc/apache2/2.4/httpd.conf.
I have put this in the same file :
Alias /phpmyadmin #{HOMEBREW_PREFIX}/share/phpmyadmin
<Directory #{HOMEBREW_PREFIX}/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
I use virtual host, so i create a symlink of the folder /usr/shar/phpmyadmin in /Users/username/Sites and create a phpmyadmin.conf like this:
<Directory "/Users/amerej/Sites/phpmyadmin">
Allow From All
AllowOverride All
Options +Indexes
Require all granted
</Directory>
<VirtualHost *:*>
ServerName phpmyadmin.localhost
DocumentRoot "/Users/amerej/Sites/phpmyadmin"
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9071/Users/amerej/Sites/phpmyadmin/$1
</VirtualHost>
I user follow this tutorial for using multiple versions of php :
https://lukearmstrong.github.io/2016/12/setup-apache-mysql-php-homebrew-macos-sierra/
Thank you if can help me i try to solve my problem alone but don't find the solution.
I've been reading up on this on the web, but still could not figure out how to implement it properly. I'd greatly appreciate if you could help me understand how to make url rewrite work without .htaccess.
To check if mod_rewrite is enabled, I ran command ~# sudo apachectl -t -D DUMP_MODULES. It produced, among others the following module: rewrite_module (shared). I don't know if it is the same as mod_rewrite?
Folder /etc/apache2/mods-enabled/ has file rewrite.load
I'm not clear which file exactly I should add rewrite rules to?
File httpd.conf located in /etc/apache2/ is empty. However there's a file named 000-default located in /etc/apache2/sites-enabled/ and it looks like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I'm not clear at all where I should add rewrite rules. I tried adding them to this 000-default file into <Directory /var/www/> section, but it did not work.
You put the rewrite code in the directory block where you're have the .htaccess file (if you use them). For example if /var/www is your docroot, you could put it their:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
</Directory>
If you are using apache 2.2.16 or newer, use
FallbackResource /index.php
I have a problem with my apache2, the url rewriting don't work and I don't know why...
In my phpinfo(), I have:
Loaded Modules: mod_rewrite
My .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^test\.html$ /test.php [L]
My Apache config:
<VirtualHost>
ServerAdmin mail#gmail.com
ServerName www.site.com
ServerAlias site.com
DocumentRoot /var/www/site.com/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/site.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I think my config is right, but I really don't know why my rewriting don't work... Have you an idea ?
Thanks you so much !
For this particular rule:
RewriteRule ^test\.html$ /test.php [L]
Mod_negotiation is going to try to deal with it for you. You want to turn Multiviews off if you want that to work:
Options -Multiviews
at the top of your htaccess file, or remove it from your <Directory> container:
<Directory /var/www/site.com/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
So I have the following .htaccess in my /var/www/site
RewriteEngine on
RewriteRule ^([^/]+)/?$ parser.php?id=$1 [QSA,L]
I have allowed override in my vhost:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/site>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
UPDATE:
Now I got it to work, however when I visit site.com, it also redirects me to this parser.php, in which I don't want as this is my homepage.
My homepage should be redirected to index.php and if I do mysite/NASKDj, it should be redirected to parser.php?pid=NASKDj. How do I fix this?
You have 'AllowOverride None' in the '/var/www/site' directory - this will overrive the one specified in the '/' directory. If your site is in /var/www/site you need to change This one to All too.
I just saw AllowOverride None in your <Directory /var/www/site>...</Directory>, So?