so I just implemented the YOURLS script successfully, or so I thought.
It generates the shortened URL succesfully and adds it too the YOURLS url ID table, but when I try and navigate to the website, via using the new shortened url. I always get the same error message in the browser.
Not Found
The requested URL /4 was not found on this server.
Apache/2.4.3 (Unix) Server at scof.me Port 80
Most appreciated if you could help!
YOURLS has information on creating the .htaccess file manually on this page.
For a root install, the file has to look like this:
Case: YOURLS installed on root
If YOURLS root URL is http://www.example.com/, the .htaccess file in the root directory must be like:
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /yourls-loader.php [L]
</IfModule>
# END YOURLS
I had the same problem on amazon aws ubuntu 12 and solved here:
https://askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache
"If you plan on using mod_rewrite in .htaccess files, you also need to
enable the use of .htaccess files by changing AllowOverride None to
AllowOverride FileInfo. For the default website, edit
/etc/apache2/sites-available/default:"
And yes I plan on using mod_rewrite in .htacess then..
Then you have to restart apache.
Related
I recently grabbed a host and first there was an index2.html in my htdocs root which was default index, I didn't remove that until I install wordpress in that root. then wordpress automatically made a httaccess file with following codes which is normal:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
now I realize that sometimes there is /?i=1 or /?i=2 in my general url, for example, wordpresssite.com/?i=2
this is a problem because I'm using some ad-unit system and I gave my website url to the system but it seems that the ad system bots some time redirect to "wordpresswebsite.com/?i=2" url and it does not match with the url I entered before (wordpresswebsite.com) so it's not gonna work.
now I removed the index2.html but the problem is still there.
this ?i=1 or 2 is about PHP GET parameter but how this parameter will appear.
I found this on reddit with similar issue and the conclusion was:
Most likely there are some rules at vhost level.
---- yes it's from the host, they said they cannot disable it as it's protecting me from bots.
For those interested in removing the /?i=1 installed mostly by free host providers here's a tip.
Edit & upload the .htaccess file in root of website
RewriteCond %{QUERY_STRING} ^(.*)\?i=1$ [NC]
RewriteRule ^(.*)$ /$1?%1 [R=301, L]
If you're using Apache, you have to enable mod_rewrite first.
sudo a2enmod mod_rewrite
Then restart or reload your server for the new configuration to take place:
sudo service apache2 restart
(Try to find some fancy control panel option for this, if not having shell access)
?i=1 or 2 or 3 is to protect your website from bots. Try using cloudflare for your website or use the .htaccess code to remove ? paramaters. Note that using any code to remove ?i=1 will remove all ? parameters.
My wordpress site lies in a folder called /entwurf/cob1 and since I wanted it to be shown by simply typing in www.cob1.org I changed the permalink to cob1.org and now nothing works. I tried changing the htacces to:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /entwurf/cob1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /entwurf/cob1/index.php [L]
</IfModule>
but this doesnt seem to work either. I want my files who lie in the entwurf/cob1/ folder to be shown when typing in the cob1.org website.
Currently nothing is seen.
Delete .htaccess, log into your wordpress, and let wordpress to generate .htaccess for you. ( Options -> Permanent Links -> Save)
Check is it working? No?
Upload to your web site root phpinfo file (php file with a content of "<?php phpinfo() ?>"), run it via browser.
Check what Server API cell says -> Apache? If yes Check is there mod_rewrite enabled? No? Ask Support to enable it.
If its not a Apache, ask for a help of the person who setup your server.
If you have access to the Worpdress admin panel go to
Setting > General
and make sure the Wordpress URL and Site URL are correct. They should be your new address. Change those and save it if you want to rewrite all the old URLS in the database.
If you don't have access to the WP admin panel try using this to manually make the changes to your database.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Delete .htaccess and regenerate it. Else use the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /entwurf/cob1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
Secondly, what you are trying to achieve has to be done in two steps.
1) In Settings > General, change the wordpress url in both fields to www.cob1.org
2) In your apache config, set www.cob1.org to point to /entwurf/cob1/
<VirtualHost *:80>
DocumentRoot "complete-absolute-path-to/entwurf/cob1/"
ServerName cob1.org
ServerAlias www.cob1.org
</VirtualHost>
3) Verify that .htaccess is being read. This takes a little bit of experimentation. Eg. I'd place some random text in .htaccess to force a server error on purpose. If I see the error, that means that the .htaccess file is being read. If it's not being read, make sure "AllowOverride All" is set in the apache config. .htaccess files are only read by apache (and apache family servers.)
Restart apache. You're done.
I recently installed wordpress , I am facing issues when I try to change the permalinks format ,
when I change the permalink from default to day and time
Default http://127.0.0.1/?p=123
Day and name http://127.0.0.1/2015/03/16/sample-post/
the link generated does't working , it gives the same error 404 all the
time ,
The requested URL /2015/03/16/post-5-problem/ was not found on this server.
But when the permalink type was default this works perfectly.
I found some solutions which are
sudo a2enmod rewrite
Module rewrite already enabled
Another solution is to change the mode permissions of .htaccess file to 666(giving write permission to wordpress of .htaccess file) before change the permalink from default to some other type ,
sudo chmod 666 /address_of_.htaccess
i checked the .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
but the above seems to be correct , the above included by the wordpress itself
Both the solutions does't seem to work , is there any other thing do I have to change to enable the permalink options ?
If it is a fresh install of web server it is possible that .htaccess rules are not allowed by default. To fix that, edit you httpd.conf (usually it is in /etc/apache2), find
<Directory "path/to/your/document/root">
# ....
AllowOverride None
# ....
</Directory>
and change
AllowOverride None
to
AllowOverride All
Then restart your web server and try again.
Reset your desired permalink from wordpress admin area and add this code in htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Now, check with blog posts and pages.
Thanks,
You can go to preferences -> services & ports and you need to check enabled ssl for Apache
It's working for me
You are receiving this error because your webserver cannot find the file, and it's not passing the request to Wordpress.
You need to add rewrite rules for your Wordpress, and instructions for that depend on your webserver software (Apache, nginx, etc).
Example with nginx:
location / {
try_files $uri $uri/ /index.php?$args;
}
Which literally means: try to open "/2015/03/16/post-5-problem/" in filesystem first, if it doesn't exist try to add a slash, if that doesn't help pass the request to index.php (which is Wordpress main file) with the arguments.
Enabling rewrite module is not enough, you have to add rewrite rule(s).
I have three web servers on three separate computers. I am trying to install a php application that rewrites all url requests to index.php (front controller pattern). The following .htaccess works on two out of the three web servers:
RewriteEngine On
# Redirect everything to the Front Controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^(css|images|files)/ index.php [NC,L]
So, when I visit http://example.com/hithere, index.php is called and I can then parse the originally requested url (hithere) to figure out what controller to send it to.
However, for some unknown reason, the above .htaccess file doesn't work on the third webserver. Instead, when I access http://example.com/hithere, I get a 404 not found error in my browser that says this:
The requested URL /full/path/to/application/index.php was not found on this server.
So, based on the above error, I can tell that it's actually trying to redirect to index.php. But the file that the browser lists in the /full/path/... below is actually on my web server - so I have no idea why it can't find it. Could someone please help me and tell me what I'm doing wrong?
Edit: I don't know if something in the httpd.conf could be conflicting, but here are the settings I have in httpd.conf for the directory that this application is in
Alias /myapp /full/path/to/my/app
<Directory /full/path/to/my/app>
Order allow,deny
AllowOverride All
Allow from all
</Directory>
Edit 2: I noticed something peculiar in the Apache logs. It looks Apache is appending index.php, which I am trying to redirect traffic to, to the DocumentRoot:
File does not exist: /document/root/full/path/to/my/app/index.php
When it should be going to:
/full/path/to/my/app/index.php
So I basically need to tell htaccess to ignore the document root. I tried this by specifying this in my .htaccess file:
RewriteBase /full/path/to/my/app/
But it's still searching the document root for index.php :/ Is there a way to reset the DocumentRoot or tell htaccess to ignore it when rewriting to index.php? Even when I use the absolute path in the RewriteRule, it still appends it to the document root.
RewriteEngine On
# Redirect everything to the Front Controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^(css|images|files)/ /full/path/to/my/app/index.php [NC,L]
It doesn't make sense to me... Can someone please help?
Thanks
So, based on the above error, I can tell that it's actually trying to
redirect to index.php. But the file that the browser lists in the
/full/path/... below is actually on my web server - so I have no idea
why it can't find it.
Assuming it's a *nix alike system, you might want to check file permissions and make sure that the webserver has read access to the file.
You also need to check the DocumentRoot parameter in httpd.conf
Look for something like this in the file and make sure it's correct. That is also where apache will be getting it from.
DocumentRoot "/var/www/html/path/to/whatever"
Also I would disable SELinux if it's on and you really don't need it because it causes weird problems too.
First enable rewrite module in apache by using $ sudo a2enmod rewrite then restart web server by $ sudo systemctl restart apache2
Put following code in your virtual host.
<Directory /var/www/html/your_app_folder>
Order allow,deny
AllowOverride All
Allow from all
</Directory>
then add following code in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I have a friendly URL module redirecting my index page to a search page. If I write index.php with my link then it redirects me to index page. If I try to access registration page it gives me error
ABS_PATH is not loaded. Direct access is not allowed.
If I try to access any category it gives me an error such as
Not Found
The requested URL /for-sale_1/toys-games-hobbies_1/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I have checked my error log it is giving me this error
<IfModule mod_rewrite.c> is without </Ifmodule>
Works great on the local server, but not on the remove live using Apache.
Category links work on the live site but when I click to register or login or publish link it gives the error:
ABS_PATH is not loaded. Direct access is not allowed.
Here is the rule for register that is defined in generate_rules.php
$rewrite->addRule('^user/register$', 'index.php?page=register&action=register');
define('REL_WEB_URL', '/home/xxx/public_html');
define('WEB_PATH', 'xxx.com/';);
You should disable MultiViews option. Write the following line in your .htaccess file (it should be in the root folder of your OSClass installation):
Options -MultiViews
Moreover, you should make sure that the .htaccess file exists.
Try disabling negotiation module of apache or disabled MultiViews directive in server's configuration and/or .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]
Options -MultiViews
</IfModule>
create .htaccess file , copy root folder working!