Apache 2.4 config include files appear to be ignored - include

I have an apache2 site config that works perfectly. When I place some of the directives into an include file the rewrites are no longer processed.
They all work when in a single conf file.
mod_info http://{server name}/server-info shows the directives loaded when either a single file or with include files.
If an include file has the wrong name or wrong permissions apache2 fails at start.
Single conf file or with multiple includes passes apachectl -t syntax check.
Example code is
<VirtualHost *:80>
.....
include /etc/apache2/includes/site80.conf
</VirtualHost>
site80.conf has:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteRule .* - [E=junk:1,L]
I can find nothing else required to make the includes work, and apache appears to load them according to mod_info.
Can anyone shed any light why the includes appear to be ignored?
Thanks

Related

Laravel 404 error with xampp

I am starting to learn how to work with laravel but got a problem. When I go to: http://localhost/testing/public/ I get a working page but when I typ for example http://localhost/testing/public/home which is one of my views I get a 404 error. Does someone know how to fix this?
Edit:
I am using the latest version of laravel and when I do for example:
Route::view('/home', 'home');
In my routes/web.php I get that error
This is more likely a problem with virtual Hosts, try the following:
First edit your route to :Route::get('/home', function(){echo
"hello"});
Then try to access: http://localhost/testing/public/index.php/home
If it works then its certainly because you don't have a virtualHost, you can set it easily in your Xampp config and modifying ur hosts file
First go to C:\Windows\System32\drivers\etc\hosts and add a new
line like: 127.0.0.1 yoursite.local
Then go to where xampp is installed under
xampp\apache\conf\extra\httpd-vhosts.conf
Then add a virtual host in the bottom of the file like:
<VirtualHost *:80>
DocumentRoot "PATH_to_laravel_folder/public"
ServerName yoursite.local
</VirtualHost>
Then you can access your route by typing: yoursite.local/home or
yoursite.local:80/home
Hope it helps you guys :)
It may be because of routes.
after creating a view you have to add it in routes/web.php
like Route::view('/yourUrl', 'viewName'); in 5.5 version.
for 5.4 or older versions Route::get('/yourUrl', 'viewName');
after adding this to routes/web.php. you can access http://localhost/testing/public/yourUrl
you can find more here
If http://localhost/testing/public/index.php/home works, try to create a .htaccess file in public directory with:
RewriteEngine On
RewriteBase /testing/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Run $ composer install in you command line

issue with shifting Kohana 2.4 from root location to make it accessible via a directory?

I have developed a kohana project 2.4 version, with i has been developed by configuring virtual host and we are accessing it using some domain aa.com, now i have to move the project to folder named kohana and make it access via aa.com/kohana. If i access it this way then my url changes, So the css & js file are not included since the src url i have provided like /public/css/ so it's not working, same goes for calling a controller. like il be calling a controller using this format /user/login/. now the url when i click to shows like aa.com/user/login which is not found, in turn it should automatically comes like aa.com/kohana/user/login. Is there any way by changing the htaccess file or hacking routes.php file. ?
I should able to automatically append /kohana/ before the url.
Please suggest me a method how it can be achieved.
Yes there is!
I've only started after kohana 3.0 but you can just change the rewritebase.
In your .htacces it probably says "rewritebase /"
Change this to your new directory. "rewritebase /kohana/"
If 2.4 has a bootstrap (i'm not sure) somewhere it should say "base_url". You change this the same as the .htaccess. /kohana/.
edit: here's an example:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /kohana/
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

How to use mod_rewrite in Apache2?

I´m trying to do a simple redirection with Apache2 with mod_rewrite. I've installed the module in my Apache and I´ve set a webpage in localhost/file1/file2/page.html. I´m writing this in my 000-default file:
RewriteEngine On
RewriteRule elegantdirectory/page.html file1/file2/page.html [L,NC]
So now if I try to access to localhost/elegantdirectory/page.html, the server is supposed to show me the page.html I have in file1/file2. Any ideas why isn't it working?
Try including bounds and a leading slash in your RewriteRule:
RewriteRule ^/elegantdirectory/page.html$ /file1/file2/page.html [L,NC]

Magento URL issues

I am still new to magento but I have been slowly making progress on replicating the production environment to a sandbox environment.
The issue I am currently running into is that when I go to my site I get a long url rather than a short optimized url. I am guessing it is a configuration setting that I need to change as well as, I went through and had to add index.php to the url string for it to work properly.
What I want to be able to do is use a short url such as /category/page.html rather than catalog/category/view/s/power-tools/id/261/
Thank you in advance!
This is probably because you need to reindex Catalog URL Rewrites. Go to System->Index Management and reindex. (It's probably best to select all and reindex though just to be sure!)
After working through this, I ended up changing the .htaccess Mage::run() settings. I ended up having to change some of the base url setting in the core_data_config table to finish getting everything to work correctly. I also ended up having to set the SEO rewrites (System Config > General > Web > Search Engine Optimization > Use Web Server Rewrites) = No
I found that once index.php was included in the path then my site was working properly.
This is what i ended up doing and it removed the index file as well. Part of the issue is that I installed magento in /store/dir/
1) Login to admin section by using the URL
http://domain.com/index.php/admin
2) then go to “System >> Configuration >>Web >> Search Engines Optimization”
Use Web Server Rewrites : YES
3) Go to “System >> Configuration >>Web >>Secure”
Use secure URL Frontend: YES
** I used the second one **
4)Then create the .htaccess file under your the magento installed folder.
If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.
<IfModule mod_rewrite.c >
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule >
http://www.bestdesigns.co.in/blog/remove-index-php-url-magento

My mod_rewrite won't work, what's wrong?

I have the following rewrite rule, but nothing is hapenning at all when I try to use it. I have the file in the directory server.blahblahblah.com/todo and the following is my .htaccess file:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^tasks/view/([0-9]+)?/$ controller.php?task=view&id=$1
RewriteRule ^tasks/view/([0-9]+)\.xml$ controller.php?task=viewxml&id=$1
RewriteRule ^tasks/new?/$ controller.php?task=new
RewriteRule ^tasks/delete/([0-9]+)?/$ controller.php?task=delete&id=$1
RewriteRule ^tasks/completed/([0-9]+)?/$ controller.php?task=complete&id=$1
RewriteRule ^tasks?/$ controller.php?task=home
Does anyone know why this won't work at all?
Thanks,
Tim
If nothing happens at all, it might be that you didn't enable .htaccess files for your site. To do that, change your site configuration (/etc/apache2/sites-enabled/<yoursite>) to include AllowOverride All instead of AllowOverride None (the default). But mind the performance disadvantage - you could also put the rules directly in the site configuration.
In case that doesn't solve it, look at the Apache logs in /var/log/apache2/*.

Resources